Grouped Sheets

  • Thread starter Thread starter Steph
  • Start date Start date
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.
 
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
 
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
 
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
 
Back
Top