View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
AJ Master AJ Master is offline
external usenet poster
 
Posts: 29
Default Looping thru ComboBoxes on a Worksheet

Hi All,

I checked lots of posts but have not been able to find a solution for
my looping problem. Hope someone can help. I have 8 comboboxes on a
worksheet sheet and I want to reset the listindex on each one to 0.
Here's the code I used:

Application.ScreenUpdating = False

Dim sheetname As String
Dim sFormName As String

Dim a As Byte
Dim b As Byte

sheetname = ActiveSheet.Name

For a = 1 To 8
Set sFormName = "combobox" & a
Worksheets(sheetname).sFormName.ListIndex = 0
Next a

When I run the code I get "run-time error '91'" which states that
"Object variable or with Block variable not set" This occurs when its
starts to run the for loop. Can anyone tell me what I'm doing wrong?

AJ