Hide/Unhide Button help

tjktm

New Member
Joined
Mar 2, 2016
Messages
31
Worksheet contains 16 buttons labelled "0100", "0200", etc to "1600" that are used to hide/unhide rows based on cells contents. Code below:

ActiveSheet.Unprotect "password"
Application.ScreenUpdating = False
For Each cell In Range("k91:k153")
If cell.EntireRow.Hidden = True Then
cell.EntireRow.Hidden = False
Else
If cell.Value = "0" Then
cell.EntireRow.Hidden = True
End If
End If
Next cell
Application.ScreenUpdating = True
ActiveSheet.Protect "password"
End Sub

This works great as long as no rows are added or deleted within the range. When a rows are added, it pushes the same number of rows outside of the range.

Is it possible to perform the hide/unhide between two cell values/labels in Column A instead of dedicated row numbers that I have now? The beginning of each hide/unhide Range starts with a cell in Column A having text "R.x" and ending with "R.x.x". I would need the hide/unhide to start one row below "R.x" and one row above "R.x.x".

Thanks

TJL
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
Hi tjktm - Have you considered using the Group feature from the Data tab? This may allow you easily hide/unhide rows as well as adding and subtracting rows within groups. Just a thought.
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,240
Members
452,621
Latest member
Laura_PinksBTHFT

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