3

Excel VBA の場合:

特定の日付範囲のすべての日をループするにはどうすればよいですか?

'2013-01-01' から '2013-01-03' は次のようになります。

2013-01-01
2013-01-02
2013-01-03
4

1 に答える 1

13

これは、少なくとも、あなたがやろうとしていることを始める方法を示しているはずです:

  Sub test()

  Dim StartDate As Date
  Dim EndDate As Date
  Dim DateLooper As Date

  StartDate = #1/1/2013#
  EndDate = #12/31/2013#

  For DateLooper = StartDate To EndDate
     MsgBox (DateLooper)
  Next DateLooper

  End Sub
于 2013-04-04T13:12:21.540 に答える