Pookiemeister
Well-known Member
- Joined
- Jan 6, 2012
- Messages
- 626
- Office Version
- 365
- 2010
- Platform
- Windows
In my workbook I have tabs named Hats, Shirts, Pants and Shoes. Within each tabs, there is a list of the various types of clothing. For example, if hat is selected there is a list of various types of hats located in the sheet with the tab labeled hats that will populate another combobox. I found some code that displays all the tabs in a messagebox.
But I would like to display them in a combo box instead of a message box. So I tried this instead.
I then get a "Run-time error: '438': Object doesn't support this property or method" How can I fix this. Thank You.
Code:
[COLOR=#000000][FONT=Consolas]Sub WorksheetLoop()[/FONT][/COLOR]<code class="" style="box-sizing: inherit; font-family: Consolas, "Courier New", Courier, monospace; font-size: 1em;">
Dim WS_Count As Integer
Dim I As Integer
' Set WS_Count equal to the number of worksheets in the active
' workbook.
WS_Count = ActiveWorkbook.Worksheets.Count
' Begin the loop.
For I = 1 To WS_Count
' Insert your code here.
' The following line shows how to reference a sheet within
' the loop by displaying the worksheet name in a dialog box.
MsgBox ActiveWorkbook.Worksheets(I).Name
Next I
</code>[COLOR=#000000][FONT=Consolas] End Sub[/FONT][/COLOR]
Code:
Private Sub cmbClothingLine_Enter() Dim WS_Count As Integer
Dim I As Integer
cmbClothingLine.Clear
WS_Count = ActiveWorkbook.Worksheets.Count
For I = 5 To WS_Count
With cmbClothingLine
ActiveWorkbook.Worksheets(I).Name
.AddItem
End With
Next I
End Sub