4

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.

2
  • 2
    Record Macro gives very good hints. It will result in something like the answer below, but with the correct ,N:N at the end Commented Nov 18, 2016 at 22:25
  • Thanks @Slai - I hadn't noticed that the "N" by itself wouldn't be a valid range specification. Commented Nov 18, 2016 at 22:47

1 Answer 1

13
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".)

Sign up to request clarification or add additional context in comments.

1 Comment

use ``` Columns(col0 & ":" & col1).Hidden = TRUE``` instead, 'entireColumn' for some reason is super slow

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.