Need code to detect grouped sheets

  • Thread starter Thread starter Andy
  • Start date Start date
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
 
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
 
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.)
 
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





.
 

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