DELETE COLUMNS ONLY IF THERE IS NO DATA IN THE WHOLE COLUMN
If every column has a header in row 1, you could just change this line:
If Application.CountA(col) = 0 then
to
If Application.CountA(col) <= 1 then
Juan wrote:
Hello Norman,
thanks for the quick reply. Actually, I need for it to look after row 1.
Your macro does work if I delete data on row 1. Becasuse Row 1 is my headers.
So the macro will not delete because there will always be a header.
Hope this is clear sorry didn't explain it early.
Please advise how to modify to do this.
Thanks,
Juan
"Norman Jones" wrote:
Hi Juan,
Sorry, misread hide for delete.
To delete empty columns,try:
Sub Tester02()
Dim col As Range
Dim sh As Worksheet
Set sh = ActiveSheet '<<===== CHANGE
For Each col In sh.UsedRange.Columns
If Application.CountA(col) = 0 Then
col.EntireColumn.Delete
End If
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
--
Dave Peterson
|