identify selected worksheets

  • Thread starter Thread starter brzak
  • Start date Start date
B

brzak

probably very simple, but I can't quite work it out.

If more than one worksheet is selected, the code for whis action would
be:

Sheets(Array("Sheet1", "Sheet2")).Select

how do i access this information. (I would like to apply changes to
Sheet1 and Sheet2, and not to Sheet3)

thanks
 
Code acts on only one sheet at a time. If you want to update multiple sheets
you need to write code traverse through those sheets individually.
 
Thanks, though my question was how to work out which sheets are
selected. i.e. how do I work out which sheets to traverse?

I can't do this for example:

Dim A as Worksheet

For Each A in Selection
'Actions
Next A

Cheers
 
Dim sh As Object

For Each sh In ActiveWindow.SelectedSheets

MsgBox sh.Name
Next sh


--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

Thanks, though my question was how to work out which sheets are
selected. i.e. how do I work out which sheets to traverse?

I can't do this for example:

Dim A as Worksheet

For Each A in Selection
'Actions
Next A

Cheers
 
Sub which_ones()
For i = 1 To ActiveWindow.SelectedSheets.Count
MsgBox (ActiveWindow.SelectedSheets(i).Name)
Next
End Sub
 
Ah great, I didn't think to use ActiveWindow, I looked down the full
list of Worksheet/Sheet object members (at least three times) but
found nothing.

I'll have to keep ActiveWindow in mind for the future - seems to have
a lot of useful properties.

Thanks guys!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top