Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Identifying Multiple Selected Worksheets

Hi,

I'm trying to create a macro that will only affect the worksheets that are currently selected (when a user uses ctrl+click on multiple worksheet tabs). How do I identify which worksheets are selected in VBA?

Thank you very much,
-David
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 45
Default Identifying Multiple Selected Worksheets

This code shows a message box for each selected worksheet in the workbook:

For Each sh In Workbooks("BOOK2.XLS").Windows(1).SelectedSheets
MsgBox sh.Name
Next

HTH

--
Michael J. Malinsky
Pittsburgh, PA

"I am a bear of very little brain, and long
words bother me." -- AA Milne, Winnie the Pooh

"DavidMatthews" wrote in message
...
Hi,

I'm trying to create a macro that will only affect the worksheets that are

currently selected (when a user uses ctrl+click on multiple worksheet tabs).
How do I identify which worksheets are selected in VBA?

Thank you very much,
-David



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Identifying Multiple Selected Worksheets

Hi David

You can loop through them like this

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


"DavidMatthews" wrote in message
...
Hi,

I'm trying to create a macro that will only affect the worksheets that are currently selected (when a user uses ctrl+click on

multiple worksheet tabs). How do I identify which worksheets are selected in VBA?

Thank you very much,
-David



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Print selected worksheets in multiple workbooks? T & I Forms Excel Discussion (Misc queries) 1 April 3rd 10 11:52 PM
locking selected cells on multiple worksheets Andre Excel Worksheet Functions 2 December 6th 08 09:53 PM
Print selected pages from multiple worksheets Tigerxxx Excel Discussion (Misc queries) 4 December 29th 07 06:58 PM
Trouble identifying selected records richardwo Excel Discussion (Misc queries) 4 January 16th 07 01:48 PM
Identifying a Selected Range in a Macro DCSwearingen Excel Discussion (Misc queries) 4 April 25th 06 04:01 PM


All times are GMT +1. The time now is 06:48 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"