hide , unhide colums

H

hamad.fatima

I have a range of columns suppose D-O. Every month one column is
populated with the data. I want to create a Macro which can unhide the
columns with data and hide the empty columns.

thanks
 
T

Tom Ogilvy

Sub HideColumns()
Dim cell as Range, cnt as Long
for each cell in Range("D1:O1")
cnt = Application.CountA(cell.entireColumn)
if cnt < 2 then
cell.EntireColumn.Hidden = True
else
cell.EntireColumn.Hidden = False
end if
next
end Sub
 

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