Need code to detect grouped sheets

A

Andy

Hi,

I'm writing a For Next procedure that would loop through a
collection of password protected worksheets, uprotect each
and do something. However, the code would fail if some
worksheets are grouped.

Please can someone provide me with the code needed to
detect the existence of grouped worksheets and then
ungroup them.

I have failed to find anything that seems to work from the
online help such as hasarray etc.

Thanks
 
C

Chip Pearson

Andy,

Try something like

If ActiveWindow.SelectedSheets.Count > 1 Then
MsgBox "Grouped Sheets"
Else
MsgBox "No grouped sheets"
End If


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 
D

Dave Peterson

maybe just selecting the first sheet of the selectedsheets would be good enough:

ActiveWindow.SelectedSheets(1).Select

(if only one sheet is selected, no harm, no foul.)
 
A

Andy

Thanks Chip
-----Original Message-----
Andy,

Try something like

If ActiveWindow.SelectedSheets.Count > 1 Then
MsgBox "Grouped Sheets"
Else
MsgBox "No grouped sheets"
End If


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com





.
 
Top