This is what I need: Range say columns F:F, G:G, K:K. Delete the entire column if the cells are zero or blank only for these specific columns. No action if there is any other value in it.
Given below is what I am using now. But this deletes other columns that should not be deleted.
LastRow = Sheets("Sheet1").Cells(Rows.Count, 1).End(xlUp).Row
LastColumn = Sheets("Sheet1").Cells(9, Columns.Count).End(xlToLeft).Column
lastcol_name_1 = Replace(Cells(1, LastColumn).Address(False, False), "1", "")
'to find letter of last column
With Sheets("Sheet1")
For i = 1 To LastColumn
lastcol_name_1 = Replace(Cells(1, i).Address(False, False), "1", "") 'to find letter of last column
If(lastcol_name_1=“K” or lastcol_name_1=”L” or lastcol_name_1=”M”) then ‘write the column name here
If Evaluate("sum(countif(" & .Range(.Cells(10, i), _
.Cells(LastRow, i)).Address & ",{"""",0}))") = LastRow - 10 + 1 Then _
.Columns(i).Delete
Endif
Next i
For i = LastColumn to 1 step -1
– Scott CranerIf i >=11 And i <=13 then
– Scott Craner