Hi!
I found this VBA code that helps me select a specific range when clicking on a cell and unselecting it when clicking on another cell:
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
However I can't seem to figure out how I multiply this action. 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.
Also it would be ideal if it only applies when clicking on the cell (or for example only with CNTRL+click combo) so that it does not open, hide when I go over it with browsing through arrow keys.
If any help is available that will be appreciated!
I found this VBA code that helps me select a specific range when clicking on a cell and unselecting it when clicking on another cell:
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
However I can't seem to figure out how I multiply this action. 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.
Also it would be ideal if it only applies when clicking on the cell (or for example only with CNTRL+click combo) so that it does not open, hide when I go over it with browsing through arrow keys.
If any help is available that will be appreciated!