View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Norman Jones Norman Jones is offline
external usenet poster
 
Posts: 5,302
Default DELETE COLUMNS ONLY IF THERE IS NO DATA IN THE WHOLE COLUMN

Hi Juan,

Try something like:

Sub Tester01()
Dim col As Range
Dim sh As Worksheet

Set sh = ActiveSheet '<<===== CHANGE

For Each col In sh.UsedRange.Columns
col.EntireColumn.Hidden = Application.CountA(col) = 0
Next col

End Sub


---
Regards,
Norman



"Juan" wrote in message
...
Hi,
need to delete any column only if there is no Data in the whole column
Sample data i Have:
PART# Apr03 Apr04 Apr05 Aug03 Aug04
Dec03

ZDTD1 0.0247 2.5 2.4
KEF4 0.1349 538 2.6

So my end result should be:
PART# Apr03 Apr05 Aug03 Dec03
ZDTD1 0.0247 2.5 2.4
KEF4 0.1349 538 2.6

Please advise. Appreciate any feedback/help

Thanks,
Juan