How do I detect if a sheet is selected?

  • Thread starter Thread starter LowellSpecht
  • Start date Start date
L

LowellSpecht

If there are multiple sheets selected and there are some that are not
how can I detect in VBA, which are selected and which aren't in a Fo
loop? I want to perform an action if a sheet is selected and ignore
sheet if it isn't selected. A collective selection technique won'
work such as "With Selection", as I need to have the sheet name for th
rest of the loop to work.

Thanks for any tips
 
See the 'SelectedSheets' property in the Object Browser. There is an
example given that you should be able to adapt.

HTH
Paul
 
You can use SelectedSheets
See the VBA help

Sub test()
Dim sh As Worksheet
For Each sh In ActiveWindow.SelectedSheets
MsgBox sh.Name
Next sh
End Sub
 
Back
Top