I have 10 Comboboxes on the same Worksheet. I named the first 5 of them "P1A1" to "P1A5", whereas the latter 5 were named "P2A1" to "P2A5".
If I want to hide all 10 comboboxes at once using a command button, here's the current code I am using:
Code
Private Sub CommandButton1_Click()
Sheet1.P1A1.Visible = False
Sheet1.P1A2.Visible = False
Sheet1.P1A3.Visible = False
Sheet1.P1A4.Visible = False
Sheet1.P1A5.Visible = False
Sheet1.P2A1.Visible = False
Sheet1.P2A2.Visible = False
Sheet1.P2A3.Visible = False
Sheet1.P2A4.Visible = False
Sheet1.P2A5.Visible = False
End Sub
Display More
I wonder if they are ways to simplify the codes above (using loops for instance) since I plan to add more comboboxes with similar naming conventions.