ranopano
ranopano

Reputation: 539

How to hide multiple sets of columns in VBA?

I would like to hide certain columns when a macro is run. How do I do this?

I know how to do it by a range of columns ("B:D") using:

Columns("B:D").EntireColumn.Hidden = True

But I'm not sure how to specify multiple columns that are not next to each other.

I would need to hide columns: B, C, F, G, I, J, K, L, N.

Upvotes: 4

Views: 30930

Answers (1)

YowE3K
YowE3K

Reputation: 23994

Range("B:C,F:G,I:L,N:N").EntireColumn.Hidden = True

(Edited to fixed the bug noticed by Slai - have to have "N:N" and not just "N".)

Upvotes: 13

Related Questions