PDA

View Full Version : [SOLVED:] Selected Sheets Count



sherifhanna
03-04-2017, 07:56 AM
Greetings Friends,

I'm writing a Sub to swap cells values. I'm accounting for a range of errors the user may commit, one of which is having more than one sheet selected.

However, I'm not sure how to test for that condition.

I'm thinking of something along the lines of the "Count" property of the cells range, but can't figure it out.

To give you an example of what I'm trying to do, here's how I'm picturing the code:

If [condition: selected sheets > 1] Then
MsgBox "You've selected too many sheets" & vbNewLine & "Please select one sheet"
End If
Exit Sub

I need help figuring out how to account for that condition in VBA language.

Please and thank you so much

S.

Paul_Hossler
03-04-2017, 08:50 AM
Try



If ActiveWindow.SelectedSheets.Count > 1 Then

sherifhanna
03-04-2017, 09:08 AM
A Gentleman and a Scholar. Thanks Paul.

Paul_Hossler
03-04-2017, 09:19 AM
A Gentleman and a Scholar. Thanks Paul.

Well .. maybe a LONG time ago

You can mark your thread SOLVED by using [Thread Tools] in the menu above your first post