my program does what I expect to do. I'm not happy with the last loop.
Option Explicit
Public Sub calendar()
Dim i, j
Dim mDay As Date
For i = 1 To 12
Cells(1, i + 1).Value = MonthName(i)
For j = 2 To 32
If IsDate(j - 1 & "/" & i & "/" & Year(Date)) Then
mDay = CDate(j - 1 & "/" & i & "/" & Year(Date))
Cells(j, i + 1).Value = mDay
If Weekday(mDay) = 1 Then
Cells(j, i + 1).Interior.Color = vbRed
ElseIf Weekday(mDay) = 7 Then
Cells(j, i + 1).Interior.Color = vbYellow
Else
Cells(j, i + 1).ClearFormats
End If
Cells(j, i + 1).Value = Format(mDay, "DDDD")
End If
Next j
Next I
For i = 1 To 31
Cells(i + 1, 1).Value = i
Next i
End Sub
I already have a loop that counts to 31 but if I put it in there it would be executed 12 times. is there a smarter way to do it?
dim i,jis terrible indeed, I would replace it bydim index_month, index_day as integer:-)