How to hide and show a grouped column via VBA code?

  • Thread starter Michiel via OfficeKB.com
  • Start date
M

Michiel via OfficeKB.com

Hi,

I can Group a column e.g. via:

columns(3).columns.group

When I do this the result is a line on top of col C and D with a little box I
can click on to hide column C. Leaving just a box with a little PLUS above
column D.

How can I appy that directly via VBA code?

Thanks!
 
J

JLatham

Try playing with this just a bit:

ActiveSheet.Outline.ShowLevels RowLevels:=0, ColumnLevels:=1

for your example, ColumnLevels:=1 will hide column C and display the +, and
if you follow it later with same statement with ColumnLevels:=2, then you are
back to column C visible plus the line and the - symbol.

Don't forget that their is also an .Ungroup method to go along with the
..Group method.

Hope this helps some.
 
M

Michiel via OfficeKB.com

Hi JLatham,

This is exactly what I needed!
Thanks for pointing me in the right direction!!

M.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top