![]() |
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 |
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 |
All times are GMT +1. The time now is 10:56 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com