Unhide rows on another sheet based on activex checkbox value

pg1955

New Member
Joined
Jul 13, 2022
Messages
5
Office Version
  1. 365
Platform
  1. Windows
I have a VBA that is currently working correctly to unhide various sheets based on when their respective checkbox is checked. Now I want to also unhide several rows on another tab called "new business checklist". This is what I have tried but I can't seem to make it work. The red text was what I am thinking will unhide the rows. Trying to unhide rows 25 to 42.

Private Sub CheckBox1_Click()
On Error Resume Next
ThisWorkbook.Sheets("package risk analysis").Visible = CheckBox1.Value

End Sub

Private Sub unhidespecificrows()
ThisWorkbook.Sheets("new business checklist").Visible = CheckBox1.Value
For i = 25 To 42
Rows(i).Hidden = False
Next i

End Sub


Private Sub CheckBox2_Click()
On Error Resume Next
ThisWorkbook.Sheets("auto risk analysis").Visible = CheckBox2.Value

End Sub

Private Sub CheckBox3_Click()
On Error Resume Next
ThisWorkbook.Sheets("excessumbrella risk analysis").Visible = CheckBox3.Value

End Sub

Private Sub CheckBox4_Click()
On Error Resume Next
ThisWorkbook.Sheets("reinsurance").Visible = CheckBox4.Value

End Sub

Private Sub CommandButton1_Click()

ThisWorkbook.Sheets("Notes").Visible = True
ThisWorkbook.Sheets("Notes").Select

ThisWorkbook.Sheets("Notes").Range("A13").Select
ActiveCell.EntireRow.Insert Shift:=xlDown

Sheets("Notes").Range("A13:B13").Select
Selection.Borders.Weight = xlThin

ThisWorkbook.Sheets("Notes").Range("A13").Select
Selection.Formula = "=today()"

With Selection
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlBottom
.WrapText = True
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Selection.Columns.AutoFit

End Sub
 

Attachments

  • Screenshot 2022-07-29 121852.jpg
    Screenshot 2022-07-29 121852.jpg
    136.5 KB · Views: 3

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
Update: more research led me to this. This is working as expected to unhide the rows. But, I want them to hide again when the box is not checked. Help please!

Private Sub CheckBox1_Click()
On Error Resume Next
ThisWorkbook.Sheets("package risk analysis").Visible = CheckBox1.Value
Sheets("New Business Checklist").Select
Selection.EntireRow.Hidden = False
Rows("20:46").Select
Sheets("package risk anaysis").Select

End Sub
 
Upvote 0
Another Update: I have figured out how to unhide. However when I check box 1 the range from the checkbox 2 sub appears, not the range from checkbox 1. Not sure how to break these up so that after each sub only those rows appear and disappear.

Private Sub CheckBox1_Click()
On Error Resume Next
ThisWorkbook.Sheets("package risk analysis").Visible = CheckBox1.Value
Sheets("New Business Checklist").Select
Selection.EntireRow.Hidden = Not CheckBox1
Rows("25:42").Select

End Sub

Private Sub CheckBox2_Click()
On Error Resume Next
ThisWorkbook.Sheets("auto risk analysis").Visible = CheckBox2.Value
Sheets("New Business Checklist").Select
Selection.EntireRow.Hidden = Not CheckBox2
Rows("43:60").Select

End Sub
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,171
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top