The simplest way is to convert to date, and loop on the date, like this.
Code:
Dim myVar As String
Dim StartDate As Date
Dim EndDate As Date
Dim ThisDate As Date
myVar = "02-2018"
StartDate = CDate(myVar)
EndDate = DateAdd("d", -1, DateAdd("m", 1, StartDate))
For ThisDate = StartDate To EndDate
Debug.Print ThisDate
Next
-George
Microsoft SQL Server MVP My Blogs SQLCop twitter
"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.