Macro to hide many blank columns at once?

  • Thread starter Thread starter John Gorman
  • Start date Start date
J

John Gorman

Rather than selecting and hiding columns without data (other than header),
is there a macro or something that will hide them all at once? Say I have 50
columns, but only 10 have data and they are not side by side, but maybe
column A,B, D,G,AB etc while the rest are blank. Hope I have explained this
in enuf detail.

Thanks in advance if you have an answer.
 
a couple of ways

Sub hidecols()
For Each c In Range("a1:j1")
If c.Value = "" Then c.EntireColumn.Hidden = True
Next
End Sub

Sub hidecols1()
Range("a1:j1").SpecialCells(xlCellTypeBlanks).EntireColumn.Hidden = True
End Sub
 
Don thanks for such a quick reply. We'll give'em both a try.
Thanks again!

--
John
Don Guillett said:
a couple of ways

Sub hidecols()
For Each c In Range("a1:j1")
If c.Value = "" Then c.EntireColumn.Hidden = True
Next
End Sub

Sub hidecols1()
Range("a1:j1").SpecialCells(xlCellTypeBlanks).EntireColumn.Hidden = True
End Sub

--
Don Guillett
SalesAid Software
(e-mail address removed)
John Gorman said:
Rather than selecting and hiding columns without data (other than header),
is there a macro or something that will hide them all at once? Say I
have
 
glad to help

--
Don Guillett
SalesAid Software
(e-mail address removed)
John Gorman said:
Don thanks for such a quick reply. We'll give'em both a try.
Thanks again!
 

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

Back
Top