Hiding Rows based on cell value and macro kicked off with a button.

malemke78

New Member
Joined
Mar 9, 2022
Messages
5
Office Version
  1. 365
Platform
  1. Windows
We're working on a macro to hide certain rows based on a cell's value (true, false). The idea is they select the checkboxes (in column A) next to the spec sections we want to keep in the excel file. Any checkboxes that are not selected, we would want to disappear. Each checkbox is linked to its own cell with a checked = true link.
There are checkboxes in row lines 41 to 714, but there are breaks for the Division titles.
Ideally, we would like to tie this macro to button 2304 (name pending).

Is this possible? Open to suggestions. Thanks so much!

1646842726792.png
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Hello,

This should do the trick, assign it to a button at the end. It will hide all the False rows. (There is also one to UnHide the rows; if you want that. :) )

VBA Code:
Sub HideThem()
Dim i As Integer
i = 1
    For i = 41 To 714
    If Cells(i, 1).Value = False Then
    Cells(i, 1).EntireRow.Hidden = True 'hides all the rows with a 0 in column A
    End If
Next i
End Sub
Sub UnHideThem()
    Cells.EntireRow.Hidden = False 'unhides all the rows
End Sub

Jamie
 
Upvote 0
Hello,

This should do the trick, assign it to a button at the end. It will hide all the False rows. (There is also one to UnHide the rows; if you want that. :) )

VBA Code:
Sub HideThem()
Dim i As Integer
i = 1
    For i = 41 To 714
    If Cells(i, 1).Value = False Then
    Cells(i, 1).EntireRow.Hidden = True 'hides all the rows with a 0 in column A
    End If
Next i
End Sub
Sub UnHideThem()
    Cells.EntireRow.Hidden = False 'unhides all the rows
End Sub

Jamie
Jamie!
Thanks. The only issue is the checkboxes remain behind and pile up. Is there a way to have them disappear with their corresponding row?

1646919686441.png
 
Upvote 0
Hello,

You need to set the textboxes - 'to move and size with cells'

For some reason it was disabled on mine, so:-

You select the textboxes. Go to the format tab and click the little 'more arrow'. Have a look at the image

Then they hide with the rows.

Jamie
 

Attachments

  • FormatHide.jpg
    FormatHide.jpg
    67.3 KB · Views: 5
Upvote 0
Solution
Hello,

You need to set the textboxes - 'to move and size with cells'

For some reason it was disabled on mine, so:-

You select the textboxes. Go to the format tab and click the little 'more arrow'. Have a look at the image

Then they hide with the rows.

Jamie
thank you so much for the help!!
 
Upvote 0
Hello,

You need to set the textboxes - 'to move and size with cells'

For some reason it was disabled on mine, so:-

You select the textboxes. Go to the format tab and click the little 'more arrow'. Have a look at the image

Then they hide with the rows.

Jamie
The option is disable on my checkboxes too.
1647008269455.png
 
Upvote 0

Forum statistics

Threads
1,214,925
Messages
6,122,301
Members
449,078
Latest member
nonnakkong

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