I have workbook where I have buttons for hiding and unhiding rows. So when rows are hided one button is also hided and then vise versa. Then I have range that should be hided and unhided while clicking the buttons. Is there any way to make this somehow dynamic?
The problem is that I have like 40 buttons and once I am making some edit to calculator and adding a new row to my worksheet I have to rewrite all the ranges. Ranges are in sequence so they goes like:
Range("1254:1275").EntireRow.Hidden = True
Range("1254:1275").EntireRow.Hidden = False
next one
Range("1276:1298").EntireRow.Hidden = True
Range("1276:1298").EntireRow.Hidden = False
next one
Range("1299:1350").EntireRow.Hidden = True
Range("1299:1350").EntireRow.Hidden = False
etc.
Is it somehow possible to have something like +22 instead of 1254:1275? Then +23 instead of 1276:1298 etc.?
For 40 buttons I have 80 subs (1 for hide and 1 for unhide). Each operation in own sub like so:
HIDE BUTTON:
Sub WorkshopWork_HideMe()
Application.ScreenUpdating = False
ThisWorkbook.Sheets("Price calculation").Unprotect Password:="123"
Range("1254:1275").EntireRow.Hidden = True
ActiveSheet.Shapes("Rectangle: Rounded Corners 111").Visible = True
ActiveSheet.Shapes("Rectangle: Rounded Corners 233").Visible = False
ThisWorkbook.Sheets("Price calculation").Protect Password:="123"
Application.ScreenUpdating = True
End Sub
UNHIDE BUTTON:
Sub WorkshopwnWork_UnhideMe()
Application.ScreenUpdating = False
ThisWorkbook.Sheets("Price calculation").Unprotect Password:="123"
Range("1254:1275").EntireRow.Hidden = False
ActiveSheet.Shapes("Rectangle: Rounded Corners 111").Visible = False
ActiveSheet.Shapes("Rectangle: Rounded Corners 233").Visible = True
ActiveWindow.ScrollRow = 1254
ThisWorkbook.Sheets("Price calculation").Protect Password:="123"
Application.ScreenUpdating = True
End Sub

ResizeandOffset. - SJR