PDA

View Full Version : Solved: Which sheets are select in a workbook?



ferrugo
01-19-2011, 07:52 PM
Hi everybody

I need a macro that count how many sheets are select in a workbook and wichone are selected. or just wichone are selected...


i think is very simple code, but i have no ideia.
I seached in te forum, but no answer...:dunno :banghead: :banghead: :help



Thanks everybody:beerchug:
Sorry for the poor english

kvnfrnk
01-19-2011, 11:46 PM
I had guessed, but is there a reason? It seems superfluous - the first example clearly identify the item you choose. We have code in Excel 2003 that is not in Excel 2007 and it is mainly the Select class method leaves that causes problems. I try to understand the underlying logic instead of just trying random combinations to select and activate the statements that come with the right.

GTO
01-20-2011, 03:51 AM
Hi everybody

I need a macro that count how many sheets are select in a workbook and wichone are selected. or just wichone are selected...


i think is very simple code, but i have no ideia.
I seached in te forum, but no answer...:dunno :banghead: :banghead: :help



Thanks everybody:beerchug:
Sorry for the poor english
Presuming in the active window:
Sub exa()
Dim sh
Dim msg$


For Each sh In ActiveWindow.SelectedSheets
If sh.Type = -4167 Then
msg$ = msg$ & sh.Name & vbCrLf
End If
Next

msg$ = "Selected sheets are:" & String(2, vbCrLf) & msg$ & vbCrLf & "Count is: " & _
ActiveWindow.SelectedSheets.Count
MsgBox msg$, vbOKOnly, vbNullString

End Sub Hope that helps,

Mark

ferrugo
01-20-2011, 04:06 AM
wowww....

Thanks everybody, and GTO.... :clap: :clap: :clap: :rotlaugh: :rotlaugh: :friends: :beerchug:

this is the code that a looking for.

For Each sh In ActiveWindow.SelectedSheets
If sh.Type = -4167 Then

i will study that.
many thanks

GTO
01-20-2011, 04:13 AM
You are most welcome. The -4167 is for a worksheet, so it will disregard chartsheets etc.