Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default grouping sheets

Hi Norman,

Yes, that makes sense. As you say, the way to circumvent this would be to
build an array and check against that.


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Norman Jones" wrote in message
...
Hi Bob,

Except in special cases, I believe that this will fail.It fails, for

example
if a multiple or non-contiguous selection does not include the lowest

index
sheet..
The code will fail whenever a sheet is deleted which has with a lower

index
than that of a grouped sheet. This is because the deletion removes the
worksheet grouping.
One solution to this might be to put the grouped sheets into an array and
use the array for comparison purposes.

---
Regards,
Norman

"Bob Phillips" wrote in message
...
Hi Hans,

Here is some code

Sub Grouped()
Dim sh As Worksheet
Dim sh2 As Worksheet
Dim fFound As Boolean

Application.DisplayAlerts = False
For Each sh In ActiveWorkbook.Worksheets
fFound = False
For Each sh2 In ActiveWindow.SelectedSheets
If sh.Name = sh2.Name Then
fFound = True
Exit For
End If
Next sh2
If Not fFound Then sh.Delete
Next
Application.DisplayAlerts = True

End Sub


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Hans" wrote in message
...
Im writing a macro that groups a number of sheets in an
existing workbook and performs some action on them.

I want to add a macro that deletes all the sheets that do
not belong to this group. What is the best way to do this?
The number of sheets that do not belong to the group is
not always the same so I cannot select them on sheet name
or number.

Thanks for your help.

regards
Hans







Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Grouping sheets copies Header across to all sheets James Trujillo[_2_] Excel Worksheet Functions 1 December 7th 09 08:16 PM
Grouping sheets with one hand in Excel Steve Vincent Excel Discussion (Misc queries) 2 April 5th 06 07:25 PM
Grouping Sheets keith Excel Discussion (Misc queries) 2 October 13th 05 06:00 PM
Grouping in protected sheets Maia Excel Discussion (Misc queries) 1 January 3rd 05 04:04 PM
Grouping Sheets in VBA John Pierce Excel Programming 0 January 15th 04 01:06 AM


All times are GMT +1. The time now is 05:34 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"