ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Grouped Sheets (https://www.excelbanter.com/excel-programming/433905-grouped-sheets.html)

Steph

Grouped Sheets
 
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.

--
Steph

Jim Thomlinson

Grouped Sheets
 
Use this line of code to determine how many sheets are currently selected...

ActiveWindow.SelectedSheets.Count
--
HTH...

Jim Thomlinson


"Steph" wrote:

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.

--
Steph


Rick Rothstein

Grouped Sheets
 
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

--
Rick (MVP - Excel)


"Steph" wrote in message
...
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.

--
Steph



Rick Rothstein

Grouped Sheets
 
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

--
Rick (MVP - Excel)


"Rick Rothstein" wrote in message
...
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

--
Rick (MVP - Excel)


"Steph" wrote in message
...
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.

--
Steph




Steph

Grouped Sheets
 
Thank you - works great!

--
Steph


"Rick Rothstein" wrote:

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

--
Rick (MVP - Excel)


"Rick Rothstein" wrote in message
...
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

--
Rick (MVP - Excel)


"Steph" wrote in message
...
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.

--
Steph






All times are GMT +1. The time now is 06:13 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com