PDA

View Full Version : [SOLVED:] Code to organize sheets skipping hidden or specific ones



brunces
05-11-2005, 01:03 PM
Friends,

I've got this code to organize my sheets...



Sub OrganizeSheets()

Dim TargetSheet As Worksheet

For Each TargetSheet In ActiveWorkbook.Sheets
TargetSheet.Select
Range("A1").Select
Next TargetSheet

Sheets("FirstSheet").Select

End Sub


But there's one problem... There's one HIDDEN sheet. So, when I run this macro, it doesn't work correctly.

How can I run this code SKIPPING hidden sheets?

or

How can I run this code SKIPPING a specific sheet?

Thank you for your attention, guys. :)

Hugs.

Bruno

mvidas
05-11-2005, 01:06 PM
Hey Bruno,


For Each TargetSheet In ActiveWorkbook.Sheets
If TargetSheet.Visible = xlSheetVisible And TargetSheet.Name <> "Skip this sheet" Then
TargetSheet.Select
Range("A1").Select
End If
Next TargetSheet
That shows how you can only process the visible sheets, and also shows how to skip specifics!
Matt

brunces
05-12-2005, 04:03 AM
mvidas,

Cool! Thanks a lot, buddy! :)

Bruno