I am relatively new to VBA in Excel and it has been a few years since I had VB and C+. I am needing to loop through several items including ACTIVE X comboboxes and checkboxes. Here is a sample of what is going on:
If Len(Range("A3").Value) = 0 Then
Me.ComboBox3.Visible = False
Me.ComboBox3.Value = ""
Me.CheckBox3.Visible = False
Me.ComboBox13.Visible = False
Me.ComboBox13.Value = ""
Me.CheckBox13.Visible = False
Else
If Len(Range("f3").Value) = 0 Then
Me.ComboBox3.Visible = True
Me.ComboBox3.Value = ""
Me.CheckBox3.Visible = True
Me.CheckBox3.Value = False
Else
Me.ComboBox3.Visible = False
Me.ComboBox3.Value = ""
Me.CheckBox3.Visible = False
End If
If Len(Range("I3").Value) = 0 Then
Me.ComboBox13.Visible = True
Me.ComboBox13.Value = ""
Me.CheckBox13.Visible = True
Me.CheckBox13.Value = False
Else
Me.ComboBox13.Visible = False
Me.ComboBox13.Value = ""
Me.CheckBox13.Visible = False
End If
End If
I have several comboboxes and checkboxes throughout the sheet and need to index through them to shorten the code and make it easier to follow. I want to do something like:
dim x as integer
x=3 'start with combobox3 to make combobox relative to row
do
Me.("CheckBox"&x).Visible = False
'do more stuff
x+1
do until x=50
I may have nomenclature wrong, however I hope you understand the direction I am heading.
loop
Bookmarks