ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Selecting all sheets (https://www.excelbanter.com/excel-programming/297885-re-selecting-all-sheets.html)

Dana DeLouis[_3_]

Selecting all sheets
 
I need a piece of VBA code that will select all visible sheets.

Just a slightly different technique:

Function SelectAllSheets()
'// Dana DeLouis
Dim sht As Variant

On Error Resume Next
For Each sht In Sheets
sht.Select Not sht.Visible
Next
'Return a count
SelectAllSheets = ActiveWindow.SelectedSheets.Count
End Function

--
Dana DeLouis
Using Windows XP & Office XP
= = = = = = = = = = = = = = = = =


"Erin" wrote in message
...
I need a piece of VBA code that will select all visible sheets. When I

record a macro, it does it via an array and specifying each sheet name.
But, in my case I don't know how many sheets there are.




All times are GMT +1. The time now is 12:25 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com