B
Brian
Hi everyone,
I am just starting out with VBA for the first time. Is there any way to
reference, say, columns A to C on every worksheet from Worksheet 2-4?
As an example, I want to make columns visible/hidden by way of checkboxes. I
currently do this as follows (thanks to Bob Phillips in one of the other
newsgroups):
Worksheets("Sheet2").Columns("A:A").Hidden = NOT CheckBox1.Value
Worksheets("Sheet3").Columns("A:A").Hidden = NOT CheckBox1.Value
Worksheets("Sheet4").Columns("A:A").Hidden = NOT CheckBox1.Value
Worksheets("Sheet2").Columns("B:B").Hidden = NOT CheckBox2.Value
Worksheets("Sheet3").Columns("B:B").Hidden = NOT CheckBox2.Value
Worksheets("Sheet4").Columns("B:B").Hidden = NOT CheckBox2.Value
Worksheets("Sheet2").Columns("C:C").Hidden = NOT CheckBox3.Value
Worksheets("Sheet3").Columns("C:C").Hidden = NOT CheckBox3.Value
Worksheets("Sheet4").Columns("C:C").Hidden = NOT CheckBox3.Value
Is there a way to write something more like:
Worksheets("Sheet2-4").Columns(A:A).Hidden = NOT CheckBox1.Value
I cannot seem to find the right syntax to do this. Any help would be most
appreciated.
Best regards,
Brian.
I am just starting out with VBA for the first time. Is there any way to
reference, say, columns A to C on every worksheet from Worksheet 2-4?
As an example, I want to make columns visible/hidden by way of checkboxes. I
currently do this as follows (thanks to Bob Phillips in one of the other
newsgroups):
Worksheets("Sheet2").Columns("A:A").Hidden = NOT CheckBox1.Value
Worksheets("Sheet3").Columns("A:A").Hidden = NOT CheckBox1.Value
Worksheets("Sheet4").Columns("A:A").Hidden = NOT CheckBox1.Value
Worksheets("Sheet2").Columns("B:B").Hidden = NOT CheckBox2.Value
Worksheets("Sheet3").Columns("B:B").Hidden = NOT CheckBox2.Value
Worksheets("Sheet4").Columns("B:B").Hidden = NOT CheckBox2.Value
Worksheets("Sheet2").Columns("C:C").Hidden = NOT CheckBox3.Value
Worksheets("Sheet3").Columns("C:C").Hidden = NOT CheckBox3.Value
Worksheets("Sheet4").Columns("C:C").Hidden = NOT CheckBox3.Value
Is there a way to write something more like:
Worksheets("Sheet2-4").Columns(A:A).Hidden = NOT CheckBox1.Value
I cannot seem to find the right syntax to do this. Any help would be most
appreciated.
Best regards,
Brian.