Hello,
I am trying to create a calendar and would like it to show the current month and year, below is the code I am using:
Private Sub UserForm_Initialize()
Dim i As Integer
With Me.cmbMonth
For i = 1 To 12
.AddItem VBA.Format(VBA.DateSerial(2019, i, 1), "MMMM ")
Next i
.Value = VBA.Format(VBA.Date, "MMMM")
End With
End Sub
The code runs to allow the months to show in the combo(List) box, but as soon as I add the code shown in red, to request it to always show the current month, it returns the run-time error 380 message saying 'Could not set the Value property. Invalid property value.
Any help would be appreciated as I cannot move forward with my project without this.
Thanks
Caz
I am trying to create a calendar and would like it to show the current month and year, below is the code I am using:
Private Sub UserForm_Initialize()
Dim i As Integer
With Me.cmbMonth
For i = 1 To 12
.AddItem VBA.Format(VBA.DateSerial(2019, i, 1), "MMMM ")
Next i
.Value = VBA.Format(VBA.Date, "MMMM")
End With
End Sub
The code runs to allow the months to show in the combo(List) box, but as soon as I add the code shown in red, to request it to always show the current month, it returns the run-time error 380 message saying 'Could not set the Value property. Invalid property value.
Any help would be appreciated as I cannot move forward with my project without this.
Thanks
Caz