ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   group method - is there a collection (https://www.excelbanter.com/excel-programming/354354-group-method-there-collection.html)

JimM

group method - is there a collection
 
Through a VB program, I'd like to modify some data for all rows that have
been grouped together using the .group method.

Is there a collection, object, or some other method that I can use to find
the group and traverse through it?

For example, I have the below code to group some rows:

Dim xlWB As Excel.Application
Dim rng As Range
Set xlWB = AppInstance

Set rng = xlWB.Rows("3:5")
rng.Group


At a later point in time, I want to go back through the group and modify
some of the information programmatically. What options are available?

thanks - jimm



Jim Cone

group method - is there a collection
 
jimm,

The built-in options look limited. The Range.OutlineLevel doesn't appear
to be of any benefit. See if the following can get you started...

'----------------------------
Sub GroupAndGrab()
Dim rng As Range
Dim lngN As Long
Dim strArray() As String
ReDim strArray(1 To 1000)

Set rng = Range("B7:B9").EntireRow
rng.Group
strArray(rng.Row) = rng.Address

Set rng = Rows("29:39")
rng.Group
strArray(rng.Row) = rng.Address

'do something else

For lngN = 1 To 1000
If Len(strArray(lngN)) Then
Set rng = Range(strArray(lngN))
rng.Font.Bold = True
End If
Next
End Sub
'----------------------------

Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware



"jimm" wrote in message

Through a VB program, I'd like to modify some data for all rows that have
been grouped together using the .group method.
Is there a collection, object, or some other method that I can use to find
the group and traverse through it?

For example, I have the below code to group some rows:

Dim xlWB As Excel.Application
Dim rng As Range
Set xlWB = AppInstance

Set rng = xlWB.Rows("3:5")
rng.Group


At a later point in time, I want to go back through the group and modify
some of the information programmatically. What options are available?

thanks - jimm




All times are GMT +1. The time now is 05:42 PM.

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