Thread: Selected Sheets
View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Rob Bovey Rob Bovey is offline
external usenet poster
 
Posts: 811
Default Selected Sheets

"Glen Mettler" wrote in message
...
I have a workbook that contains 25 worksheets. Suppose I select sheets 12,
15, and 21
Is there a way - programmatically - to cycle thru the sheets collection
and identify which ones have been selected?

I can count the number of sheets selected with:
SelectedSheets = ActiveWindow.SelectedSheets.Count

but I can't seem to find where I can read which ones are selected.


Hi Glen,

I'm not totally sure I understand what you're looking for, but
ActiveWindow.SelectedSheets returns a collection of the selected Sheet
objects. You can enumerate this collection like so:

Sub PrintSelectedSheetNames()
Dim objSheet As Object
For Each objSheet In ActiveWindow.SelectedSheets
''' Print sheet name to Immediate window.
Debug.Print objSheet.Name
Next objSheet
End Sub

--
Rob Bovey, Excel MVP
Application Professionals
http://www.appspro.com/

* Take your Excel development skills to the next level.
* Professional Excel Development
http://www.appspro.com/Books/Books.htm