Workbook Open Code Not Working

Grant22

New Member
Joined
Dec 28, 2016
Messages
48
Hello all, I am getting an error when I open a workbook. In a nutshell, for each sheet not named one of the sheets in the code I want to activate that sheet and add the months of the year in the combo box. Each sheet has a combobox1 on it, so I'm not sure why this isn't working. Any help is greatly appreciated. See below for the error message as well as the code:

Method or Data Member Not Found
Code:
Private Sub Workbook_Open()
Dim ws As Worksheet
For Each ws In Worksheets
If ws.Name <> "Home" And ws.Name <> "Emp's" And ws.Name <> "Metrics" _
        And ws.Name <> "Branch Performance" And ws.Name <> "EMP Performance" Then
        ws.Activate
    With ws.ComboBox1
        .Clear
        .AddItem ""
        .AddItem "January"
        .AddItem "February"
        .AddItem "March"
        .AddItem "April"
        .AddItem "May"
        .AddItem "June"
        .AddItem "July"
        .AddItem "August"
        .AddItem "September"
        .AddItem "October"
        .AddItem "November"
        .AddItem "December"
    End With
    ws.ComboBox1.Value = ""
    Next ws
End If
End Sub
 
Looks like I am late but this is my try anyway :)

Code:
Private Sub Workbook_Open()

Dim ws As Worksheet

For Each ws In Worksheets
    Select Case ws.Name
        Case "Home", "Emp's", "Metrics", "Branch Performance", "EMP Performance"
        Case Else
            ws.OLEObjects("ComboBox1").Object.Clear
            For i = 1 To 12
                ws.OLEObjects("ComboBox1").Object.AddItem MonthName(i, False)
            Next i
     End Select
Next

End Sub
 
Upvote 0

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)

Forum statistics

Threads
1,223,908
Messages
6,175,307
Members
452,633
Latest member
DougMo

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