Grouped Sheets

S

Steph

Is there a way to check for and/or display an error message in VBA if the
active sheet is grouped with another sheet?

Thanks for your help.
 
R

Rick Rothstein

You can use this function to test whether any specific sheet is in a
group...

Function IsSheetGrouped(SheetName) As Boolean
On Error Resume Next
IsSheetGrouped = StrComp(ActiveWindow.SelectedSheets(SheetName). _
Name, SheetName, vbTextCompare) = 0
End Function

Using this function, you would do your test like this...

If IsSheetGrouped(ActiveSheet.Name) Then
' Yes, it is grouped
Else
' No, it is not grouped
End If
 
R

Rick Rothstein

This slightly simpler coding appears to work as well as my previously posted
function...

Function IsSheetGrouped(SheetName As String) As Boolean
On Error Resume Next
IsSheetGrouped = ActiveWindow.SelectedSheets(SheetName).Index
End Function
 
S

Steph

Thank you - works great!

--
Steph


Rick Rothstein said:
This slightly simpler coding appears to work as well as my previously posted
function...

Function IsSheetGrouped(SheetName As String) As Boolean
On Error Resume Next
IsSheetGrouped = ActiveWindow.SelectedSheets(SheetName).Index
End Function
 
Top