VBA Excel loop through all days in a year

excel, vba

Solution

This should at least show you how to get started with what you're trying to do:

  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

Problem

In Excel VBA: How do I loop through all days in a given date range? '2013-01-01' to '2013-01-03' should give: ``` 2013-01-01 2013-01-02 2013-01-03 ```

Original source