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 |
unhide columns in named range
got it: With ActiveWorkbook.ActiveSheet
thx "blonde1030" wrote: 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 |
All times are GMT +1. The time now is 07:18 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com