Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default group/ungroup

using 2003.

Columns("F:H").Select
Selection.Columns.group
will group the colums so the user can easily hide/unhide
the columns
Columns("F:H").Select
Selection.Columns.ungroup
will ungroup the columns ONLY if the columns are
grouped. if the columns are not grouped and the "ungroup" command is
issued, an error results.

question - is there a way to capture the "grouped" status of a
spreadsheet?

meg99

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default group/ungroup

You could use something like:

Option Explicit
Sub testme()

Dim myCol As Range
Dim myRng As Range
Dim IsGrouped As Boolean

Set myRng = ActiveSheet.Range("F:G")

IsGrouped = False
For Each myCol In myRng.Columns
If myCol.OutlineLevel 1 Then
IsGrouped = True
Exit For
End If
Next myCol

If IsGrouped Then
myRng.Ungroup
End If

End Sub

But I might just ignore the error (if that's the only error that may possibly
occur):

on error resume next
Columns("F:H").Columns.ungroup
on error goto 0

The bad news with this method is that you could be ignoring an error that you
don't want to ignore--like if the worksheet is protected.

meg99 wrote:

using 2003.

Columns("F:H").Select
Selection.Columns.group
will group the colums so the user can easily hide/unhide
the columns
Columns("F:H").Select
Selection.Columns.ungroup
will ungroup the columns ONLY if the columns are
grouped. if the columns are not grouped and the "ungroup" command is
issued, an error results.

question - is there a way to capture the "grouped" status of a
spreadsheet?

meg99


--

Dave Peterson
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
group/ungroup protected sheets? RLD Excel Worksheet Functions 1 March 25th 10 06:46 PM
Ungroup and Group - Faded out SHIPP Excel Discussion (Misc queries) 0 May 19th 09 07:16 PM
Data Group and Ungroup Rebecca Excel Discussion (Misc queries) 3 January 3rd 09 09:13 AM
group&ungroup fofomama Charts and Charting in Excel 0 August 23rd 07 04:22 PM
Help with Group/Ungroup deacs Excel Discussion (Misc queries) 3 January 30th 06 04:29 PM


All times are GMT +1. The time now is 07:30 PM.

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"