Hi All,
I am new to VBA coding and I have the following query:
Background of what I want to achieve:
I have two tabs in this example.
The first tab is called "Summary".
The name for the second tab various based on the value included in cell B2 of that worksheet which is determined by a concatenate function.
I have the same formula in the summary tab in B4.
I have an activeX check box called CheckBox1 in the Summary tab.
I want the second tab to be hidden if the checkbox (CheckBox1) is not checked.
I also have certain columns that are hidden on the summary tab if the Check box is not checked.
VBA code1:
Private Sub CheckBox1_Click()
Application.Goto Reference:="Cell_B3_Hide"
Selection.EntireRow.Hidden = Not CheckBox1.Value
Dim Prod_1 As String
Prod_1 = "Product 1 - "
Set Target = Prod_1 + Range("B4")
ThisWorkbook. Sheets(Target).Visible = CheckBox1.Value
End if
End Sub
VBA code2:
Private Sub CheckBox1_Click()
Application.Goto Reference:="Cell_B3_Hide"
Selection.EntireRow.Hidden = Not CheckBox1.Value
Dim ws As Worksheet
Range("B4").Select
If InStr(ws.Name, Selection) > 0 Then
ws.Visible = CheckBox1.Value
End if
End Sub
I have tried both the codes. For both codes I get a "Run-time error '1004'".
Your assistance in this regard would be greatly appreciated.
Thanks.
I am new to VBA coding and I have the following query:
Background of what I want to achieve:
I have two tabs in this example.
The first tab is called "Summary".
The name for the second tab various based on the value included in cell B2 of that worksheet which is determined by a concatenate function.
I have the same formula in the summary tab in B4.
I have an activeX check box called CheckBox1 in the Summary tab.
I want the second tab to be hidden if the checkbox (CheckBox1) is not checked.
I also have certain columns that are hidden on the summary tab if the Check box is not checked.
VBA code1:
Private Sub CheckBox1_Click()
Application.Goto Reference:="Cell_B3_Hide"
Selection.EntireRow.Hidden = Not CheckBox1.Value
Dim Prod_1 As String
Prod_1 = "Product 1 - "
Set Target = Prod_1 + Range("B4")
ThisWorkbook. Sheets(Target).Visible = CheckBox1.Value
End if
End Sub
VBA code2:
Private Sub CheckBox1_Click()
Application.Goto Reference:="Cell_B3_Hide"
Selection.EntireRow.Hidden = Not CheckBox1.Value
Dim ws As Worksheet
Range("B4").Select
If InStr(ws.Name, Selection) > 0 Then
ws.Visible = CheckBox1.Value
End if
End Sub
I have tried both the codes. For both codes I get a "Run-time error '1004'".
Your assistance in this regard would be greatly appreciated.
Thanks.