Private Sub cmdCalendar_Click()
'If you're planning to use matrix for more than just
'temporay holder of values to be inserted into spreadsheet
'then change to an array of 365 elements.
ReDim Calendar(1 To 12, 1 To 365) As String
Dim ADate As String
Dim DOW As Integer
Dim Mth As Byte, NumDays As Byte, D As Byte
For Mth = 1 To 12
NumDays = DaysinMonth(Mth)
For D = 1 To NumDays
ADate = Format$(Mth, "00"

& "/" & Format$(D, "00"

& "/" & txtYear
'Check for bank holidays. Assuming if bank holiday falls on
'a weekend then display 'Weekend'.
If IsBankHoliday(ADate) Then
ADate = "Holiday"
Else
DOW = Weekday(ADate, vbUseSystemDayOfWeek)
If DOW = vbSaturday Or DOW = vbSunday Then
ADate = "Weekend"
End If
End If
Calendar(Mth, D) = ADate
Next D
Next Mth
End Sub
Private Function DaysinMonth(ByVal Mth As Byte) As Byte
Dim NumDays As Byte
Select Case Mth
Case 1, 3, 5, 7, 8, 10, 12
NumDays = 31
Case 2
'Check for leap year.
If CInt(txtYear.Text) Mod 4 = 0 Then
NumDays = 29
Else
NumDays = 28
End If
Case 4, 6, 9, 11
NumDays = 30
Case Else
NumDays = -1
End Select
DaysinMonth = NumDays
End Function
Private Function IsBankHoliday(ByVal ADate As String) As Boolean
Dim Result As Boolean
Dim i As Integer
Result = False
'Substitute your storage method of bank holidays
For i = 0 To lstHolidays.ListCount - 1
If lstHolidays.List(i) = ADate Then
Result = True
Exit For
End If
Next i
BankHoliday = Result