code hiding blank columns

Forum home » Delegate support and help forum » Microsoft VBA Training and help » Code for hiding blank columns

Code for hiding blank columns

resolvedResolved · Urgent Priority · Version 2007

Edited on Tue 11 Jan 2011, 12:30

Siphiwe has attended:
Excel VBA Intro Intermediate course

Code for hiding blank columns

Good Morning

Can you kindly send me a code to hide specific columns on a worksheet but l want.

l have a total of 108 columns, Jan (Actual,Budget,PY) - Dec (A,B,PY), l want to be able to view the current period/month & to hide the rest ...

Many thanks in anticipation!

RE: Code for hiding blank columns

Hi Siphiwe, thanks for your query. I can't really code this for you without see the source data but your main task will be to loop through the column headings performing an If...End If test to see whether the date falls within the current month. If it isn't then set the .hidden property of that column to true. Have a go and see how you get on.

Hope this helps,


Tue 25 Jan 2011: Automatically marked as resolved.


Training courses


Training information:

Welcome. Please choose your application (eg. Excel) and then post your question.

Our Microsoft Qualified trainers will then respond within 24 hours (working days).

Frequently Asked Questions
What does 'Resolved' mean?

Any suggestions, questions or comments? Please post in the Improve the forum thread.


VBA tip:

Display Text In a Msgbox On Multiple Lines

When displaying text in a MsgBox you may need to show it over multiple lines. To do this use:


As in:

MsgBox "The System has detected an error." & vbCrLf & "Contact your System Administrator"

The first sentence in quotes will appear above the second in the MsgBox.

View all VBA hints and tips

Server loaded in 0.1 secs.