Hi!
I found this VBA code that helps me hide/show a specific range when selecting one or the other cell. However I would like to use this multiple times on different cells. For instance when selecting B35 hide row 36:38 and when selecting D35 showing row 36:38. When selecting B39 hide row 40:42 and when selecting D39 showing row 40:42 and so on.
If it would also be possible to have it only trigger on CNTRL+select cell would be awesome.
Current code:
Option Explicit
Private Sub worksheet_selectionchange(ByVal target As Range)
If Selection.Count = 1 Then
If Not Intersect(target, Range("B31")) Is Nothing Then
Call HideRangeB31
ElseIf Not Intersect(target, Range("D31")) Is Nothing Then
Call HideRangeD31
End If
End If
End Sub
Private Sub HideRangeB31()
Rows("32:34").Hidden = True
End Sub
Private Sub HideRangeD31()
Rows("32:34").Hidden = False
End Sub
Thanks in advance for any tips.
I found this VBA code that helps me hide/show a specific range when selecting one or the other cell. However I would like to use this multiple times on different cells. For instance when selecting B35 hide row 36:38 and when selecting D35 showing row 36:38. When selecting B39 hide row 40:42 and when selecting D39 showing row 40:42 and so on.
If it would also be possible to have it only trigger on CNTRL+select cell would be awesome.
Current code:
Option Explicit
Private Sub worksheet_selectionchange(ByVal target As Range)
If Selection.Count = 1 Then
If Not Intersect(target, Range("B31")) Is Nothing Then
Call HideRangeB31
ElseIf Not Intersect(target, Range("D31")) Is Nothing Then
Call HideRangeD31
End If
End If
End Sub
Private Sub HideRangeB31()
Rows("32:34").Hidden = True
End Sub
Private Sub HideRangeD31()
Rows("32:34").Hidden = False
End Sub
Thanks in advance for any tips.