Unhide the next worksheet
I have 20 hidden worksheets, their names are P1 to P20 I would like to be
able to unhide the next worksheet by the click of a button. For instance if say P1, P2 and P3 were already unhiden then clicking the button would find and unhide the next worksheet P4 in this case and then if clicked again P5 would be unhidden. Can anyone help? |
Unhide the next worksheet
This should do it... I assume you can add a button and link it to this
procedure. Sub UnhideNextSheet() Dim wks As Worksheet Dim lngLast As Long lngLast = 0 For Each wks In Worksheets If wks.Visible = xlSheetVisible Then If Left(wks.Name, 1) = "P" And IsNumeric(Mid(wks.Name, 2)) Then If Val(Mid(wks.Name, 2)) lngLast Then _ lngLast = Val(Mid(wks.Name, 2)) End If End If Next wks On Error Resume Next Sheets("P" & lngLast + 1).Visible = xlSheetVisible On Error GoTo 0 End Sub -- HTH... Jim Thomlinson "MarkSussex" wrote: I have 20 hidden worksheets, their names are P1 to P20 I would like to be able to unhide the next worksheet by the click of a button. For instance if say P1, P2 and P3 were already unhiden then clicking the button would find and unhide the next worksheet P4 in this case and then if clicked again P5 would be unhidden. Can anyone help? |
All times are GMT +1. The time now is 06:17 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com