Silverjman
Board Regular
- Joined
- Mar 19, 2014
- Messages
- 110
I have a sheet1 with sets of grouped (hidden with + box or visible with the - box) columns.
Each group of hidden columns is a Named Range.
On sheet2 I have cells/formulas linking to the grouped/hidden columns/cells on Sheet1.
When I jump (doubleclick or Ctrl-G) from Sheet2 to a specific cell/column on Sheet1 I would like to automatically tigger the appropriate Named Range to Unhide. Right now the code below only unhides the column I've jumped to e.g. D:D when I would like it to unhide the entire Named Range that D:D falls into which is $B:$X.
Each group of hidden columns is a Named Range.
On sheet2 I have cells/formulas linking to the grouped/hidden columns/cells on Sheet1.
When I jump (doubleclick or Ctrl-G) from Sheet2 to a specific cell/column on Sheet1 I would like to automatically tigger the appropriate Named Range to Unhide. Right now the code below only unhides the column I've jumped to e.g. D:D when I would like it to unhide the entire Named Range that D:D falls into which is $B:$X.
Code:
Private Sub Worksheet_Activate()
Dim nm As Name, rng As Range
For Each nm In ThisWorkbook.Names
Set rng = Intersect(ActiveCell, Range(nm.RefersToRange.Address))
If rng.EntireColumn.Hidden = True Then
rng.EntireColumn.Hidden = False
End If
If Not rng Is Nothing Then
Exit For
End If
Next nm
End Sub