Home > Software design >  I am trying to write VBA code to unhide sheets in excel but not all hides sheets
I am trying to write VBA code to unhide sheets in excel but not all hides sheets

Time:07-16

i dont know why "while loop " doesn't work I dont want to unhide all sheets I need unhide by click button to unhide one sheet only and then click again to unhide another

For Each ws In ThisWorkbook.Worksheets
    If ws.Visible = False Then
    invi = invi   1
    End If
Next

Do Until invi = 1:
   ThisWorkbook.Worksheets.Visible = True
    invi = invi   1
    Loop
End Sub

CodePudding user response:

To Unhide the first hidden each time it is run:

For Each ws In ThisWorkbook.Worksheets
    If ws.Visible = False Then
        ws.Visible = True
        Exit For
    End If
Next
  • Related