I would like to hide/unhide rows with a click of a button. I have achieved this by using the following code:
Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)
omrade = ActiveCell.Row + 4 & ":" & ActiveCell.Row + 37
If Rows(omrade).EntireRow.Hidden = True Then
Rows(omrade).EntireRow.Hidden = False
Else
Rows(omrade).EntireRow.Hidden = True
End If
Exit Sub
End Sub
It works if the cell is hyperlinked to the same cell (e.g. cell D5 is hyperlinked to D5 - this would toggle the visibility of row 9 - 42).
However, I have multiple links (>100) and I do not want to manually enter each Cell Reference in the hyperlink. I have tried making dynamic hyperlinks using the Hyperlink-formula, but then my VBA code won't run.
EDIT: Tried to clarify my issue.
A1
should it toggle the visibility of rows 5 through 38? And if I click a hyperlink in cellB2
should it toggle the visibility of rows 6 through 39? etc? - Robin Mackenzie