View Full Version : Code to Group Worksheets on Open
GoKats78
08-09-2010, 05:13 AM
I'm sure this is simple...but I need a bit of code that will group all active sheets when the file is opened.
This will enable a user to print the file (from a third party application) and get all the data they need not just the active tab...
Bob Phillips
08-09-2010, 05:33 AM
All active sheets? There is by definition, just the one.
GoKats78
08-09-2010, 08:28 AM
OK..oops...I mean all "non-hidden" sheets...
Bob Phillips
08-09-2010, 08:44 AM
Try this
Private Sub Workbook_Open()
Dim SheetNames As String
Dim sh As Worksheet
With ActiveWorkbook
For Each sh In .Worksheets
SheetNames = SheetNames & sh.Name & ","
Next sh
SheetNames = Left$(SheetNames, Len(SheetNames) - 1)
.Sheets(Split(SheetNames, ",")).Select
End With
End Sub
GoKats78
08-09-2010, 09:59 AM
That's the ticket! Great! Thanks!
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.