I'm trying to delete the columns with rowcount 1.
The code checks for first two columns only.
Dim col As Long
Dim row,lastRow1 As Long
Dim iCntr1 as integer
Worksheets("Testdata").Activate
For iCntr1 = 1 To 15 ' for each column
'Finding last Row of current Column
With ActiveSheet
lastRow1 = .Cells(.Rows.count, iCntr1).End(xlUp).row
End With
If lastRow1 = 1 Then
Worksheets("Testdata").Columns(iCntr1).EntireColumn.Delete Shift:=xlToLeft
End If
Next
ActiveSheet
while your delete works on sheetTestdata
– FunThomas Nov 18 '20 at 11:28