Events
Apr 8, 3 PM - May 28, 7 AM
Sharpen your AI skills and enter the sweepstakes to win a free Certification exam
Register now!This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
You can group one or more whole rows. To create a group in a worksheet, use a NamedRange control or a native Excel range object.
Applies to: The information in this topic applies to document-level projects and VSTO Add-in projects for Excel. For more information, see Features available by Office application and project type.
If you add a NamedRange control to a document-level project at design time, you can use the control to programmatically create a group. The following example assumes that there are three NamedRange controls on the same worksheet: data2001
, data2002
, and dataAll
. Each named range refers to a whole row in the worksheet.
Group three named ranges by calling the Group method of each range. This code must be placed in a sheet class, not in the ThisWorkbook
class.
this.data2001.Group();
With Me
.data2001.Group()
.data2002.Group()
.dataAll.Group()
End With
Note
To ungroup rows, call the Ungroup method.
The code assumes that you have three Excel ranges named data2001
, data2002
, and dataAll
on a worksheet.
Group three named ranges by calling the Group method of each range. The following example assumes that there are three Range controls named data2001
, data2002
, and dataAll
on the same worksheet. Each named range refers to a whole row in the worksheet.
this.Application.get_Range("data2001");
this.Application.get_Range("data2002")
.Group();
this.Application.get_Range("dataAll")
.Group();
With Me.Application
.Range("data2001").Group()
.Range("data2002").Group()
.Range("dataAll").Group()
End With
Note
To ungroup rows, call the Ungroup method.
Events
Apr 8, 3 PM - May 28, 7 AM
Sharpen your AI skills and enter the sweepstakes to win a free Certification exam
Register now!