How can I create a loop that will go through each day in any se month and print that in column "A" and print what day of the week it is in Col "B"
What I have at the momebnt is:
--------------------------
Dim strDate As Date
Dim strMonth As String
Dim lngRow As Long
'Gets the Month and Year from Sheet 1 Cells A & B
strDate = "01/" & Sheets("Sheet1"
.Cells(1, "A"
& "/" & Sheets("Sheet1"
.Cells(1, "B"
strMonth = Month(strDate)
lngRow = 2 'The row to write in
While strMonth = Month(strDate)
Sheets("CALANDER"
.Cells(lngRow, "A"
= strDate
Sheets("CALANDER"
.Cells(lngRow, "B"
= WeekDay(strDate, vbSunday)
strDate = Day(strDate) + 1 & "/" & Month(strDate) & "/" & Year(strDate)
lngRow = lngRow + 1
Wend
--------------------------
Problems with the above Code:
1 - It will add a day until it hits the end of the month and then it will not go to the next month but will bring up a error, I guess I could trap that error but its a bit untidy, I rould rather a FOR x = 1 to 30 LOOP
2 - The day is in 1 to 7 not Monday, Tuesday Etc. I haev tried using the Format Function but I cant get anywhere, Again I could have SELECT CASE statement bit I would prefer VBA to do thw work for me.
Thanks In Advance
What I have at the momebnt is:
--------------------------
Dim strDate As Date
Dim strMonth As String
Dim lngRow As Long
'Gets the Month and Year from Sheet 1 Cells A & B
strDate = "01/" & Sheets("Sheet1"
strMonth = Month(strDate)
lngRow = 2 'The row to write in
While strMonth = Month(strDate)
Sheets("CALANDER"
Sheets("CALANDER"
strDate = Day(strDate) + 1 & "/" & Month(strDate) & "/" & Year(strDate)
lngRow = lngRow + 1
Wend
--------------------------
Problems with the above Code:
1 - It will add a day until it hits the end of the month and then it will not go to the next month but will bring up a error, I guess I could trap that error but its a bit untidy, I rould rather a FOR x = 1 to 30 LOOP
2 - The day is in 1 to 7 not Monday, Tuesday Etc. I haev tried using the Format Function but I cant get anywhere, Again I could have SELECT CASE statement bit I would prefer VBA to do thw work for me.
Thanks In Advance