Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Selected Sheets
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. Glen |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Selected Sheets
Try this if you only select worksheets and not chart sheets
Sub test() Dim sh As Worksheet For Each sh In ActiveWindow.SelectedSheets MsgBox sh.Name Next End Sub -- Regards Ron de Bruin http://www.rondebruin.nl "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. Glen |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Selected Sheets
for each sh in ActiveWindow.SelectedSheets
msgbox sh.name Next -- Regards, Tom Ogilvy "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. Glen |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Selected Sheets
Glen
You could use code to loop through the selected sheets collection Sub findSelectedSheets() Dim wks As Worksheet If ActiveWindow.SelectedSheets.Count = 1 Then MsgBox "You do not have any grouped worksheets" Exit Sub End If For Each wks In ActiveWindow.SelectedSheets MsgBox "Worksheet named: " & wks.Name & _ " is part of a group" Next wks End Sub -- HTH Nick Hodge Microsoft MVP - Excel Southampton, England HIS "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. Glen |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
Selected Sheets
The following works for me:
Dim Sh As Object For Each Sh In ActiveWindow.SelectedSheets Debug.Print Sh.Name Next Sh On Mon, 21 Feb 2005 14:30:20 -0600, "Glen Mettler" wrote: 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. Glen |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
Selected Sheets
Just what I needed. Thanks
Glen "Ron de Bruin" wrote in message ... Try this if you only select worksheets and not chart sheets Sub test() Dim sh As Worksheet For Each sh In ActiveWindow.SelectedSheets MsgBox sh.Name Next End Sub -- Regards Ron de Bruin http://www.rondebruin.nl "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. Glen |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Macro to run on selected sheets | Excel Discussion (Misc queries) | |||
Printing selected sheets. | Excel Worksheet Functions | |||
How to repeat a code for selected sheets (or a contiguous range of sheets) in a Workbook? | Excel Worksheet Functions | |||
Multiple sheets selected | Excel Discussion (Misc queries) | |||
printing selected sheets | Excel Programming |