Aretradeser
Board Regular
- Joined
- Jan 16, 2013
- Messages
- 176
- Office Version
- 2013
- Platform
- Windows
How can I simplify VBA codes, concerning the hiding or visibility of different objects?
EXAMPLE 1:
EXAMPLE 2
EXAMPLE 1:
Rich (BB code):
Private Sub UserForm_Initialize()
With Sheets("BDATOS")
n = .Range("B" & Rows.Count).End(xlUp).Row
va = .Range("G2:G" & n) 'ComboBox1 = By country of destination
vb = .Range("H2:H" & n) 'ComboBox2 = By destination city
vc = .Range("B2:B" & n) 'ComboBox3 = By name
End With
Set dar = CreateObject("System.Collections.Arraylist")
Label2.Visible = False
Label3.Visible = False
TextBox1.Visible = False
TextBox2.Visible = False
TextBox3.Visible = False
CheckBox2.Visible = False
CheckBox3.Visible = False
CheckBox4.Visible = False
Label4.Visible = False
Label5.Visible = False
Label7.Visible = False
ComboBox1.Visible = False
ComboBox2.Visible = False
ComboBox3.Visible = False
End Sub
Rich (BB code):
Private Sub OptionButton2_Click()
OptionButton1.Visible = False
OptionButton4.Visible = False
CheckBox2.Visible = True
CheckBox3.Visible = True
CheckBox4.Visible = True
Label4.Visible = True
Label5.Visible = True
Label7.Visible = True
ComboBox1.Visible = True
ComboBox2.Visible = True
ComboBox3.Visible = True
Label1.Visible = False
TextBox1.Visible = False
Label8.Visible = False
Label2.Visible = False
TextBox2.Visible = False
Label3.Visible = False
TextBox3.Visible = False
TextBox1 = ""
ListBox1.RowSource = ""
End Sub