Tefalpan
Tefalpan

Reputation: 94

Group columns and collapse

It's possible to group certain columns in Excel with the following code.

Is it also possible to collapse (hide) that group in order to hide them when plotting the sheet?

Sheets("Blad2").Select
Columns("D:H").Select
Selection.Columns.Group

Upvotes: 1

Views: 7750

Answers (1)

Andy G
Andy G

Reputation: 19367

For a column within the Group:

Set ws = ActiveSheet
ws.Columns(4).ShowDetail = False

Alternatively, define a Custom View with the columns hidden and switch to this view. Define another View with the columns visible so that you can easily switch between the Views.

ActiveWorkbook.CustomViews("test").Show

You could also create a macro that does the hiding and unhiding of columns.

Upvotes: 2

Related Questions