ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   hide , unhide colums (https://www.excelbanter.com/excel-programming/375762-hide-unhide-colums.html)

[email protected]

hide , unhide colums
 
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


Tom Ogilvy

hide , unhide colums
 
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

" wrote:

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




All times are GMT +1. The time now is 01:51 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com