View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
blonde1030 blonde1030 is offline
external usenet poster
 
Posts: 6
Default unhide columns in named range

Hello,

I received this code to unhide columns one at a time in a named range from
Dave Peterson, and it works exactly as hoped! But now spreadsheet users want
to add their own worksheets. How can I make this active sheet specific,
rather than named sheet specific?

Appreciate any help!

Option Explicit
Sub testme()
Dim iCol As Long
Dim myRng As Range
Dim UnhidACol As Boolean

With Worksheets("sheet1")
Set myRng = .Range("myrangenamehere")
End With

With myRng.Areas(1)
UnhidACol = False
For iCol = 1 To .Columns.Count
If .Columns(iCol).EntireColumn.Hidden = True Then
.Columns(iCol).EntireColumn.Hidden = False
UnhidACol = True
'get out
Exit For
End If
Next iCol
End With

If UnhidACol = False Then
Beep
End If

End Sub