Run-time error 380 in Excel VBA

Caz46

New Member
Joined
Dec 27, 2020
Messages
4
Office Version
  1. 2016
Platform
  1. Windows
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
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
Why "VBA." ?
VBA Code:
.Value = Format(now(), "MMMM")
 
Upvote 0
Hi,
welcome to forum

try adding line shown in bold below & see if this resolves your issue

Rich (BB code):
    Dim i As Integer
    
    With Me.cmbMonth
       .Style = fmStyleDropDownCombo
    For i = 1 To 12
    
      .AddItem VBA.Format(VBA.DateSerial(2019, i, 1), "MMMM ")
    
    Next i
      .Value = VBA.Format(VBA.Date, "MMMM")
    End With

Dave
 
Upvote 0
Solution
Dim i As Integer With Me.cmbMonth .Style = fmStyleDropDownCombo For i = 1 To 12 .AddItem VBA.Format(VBA.DateSerial(2019, i, 1), "MMMM ") Next i .Value = VBA.Format(VBA.Date, "MMMM") End With
Hello @dmt32.

This worked perfectly, thanks for your help.

Caz
 
Upvote 0
Why "VBA." ?
VBA Code:
.Value = Format(now(), "MMMM")
Hi eduzs,

I am using VBA as it is the best way I know to create a dynamic calendar. If you have other suggestions, I am happy to hear them.

Caz
 
Upvote 0
I just suppose that is unnecessary to add "VBA." before those functions.
 
Upvote 0

Forum statistics

Threads
1,214,979
Messages
6,122,551
Members
449,088
Latest member
davidcom

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top