I'm trying to delete the columns with rowcount 1.I have written the code,But the problem is it checks for first two columns only,even though I have given the proper values in the for loop.Can anyone please help me to check this .please find the code below.
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
Thanks In advance.
ActiveSheet
while your delete works on sheetTestdata
– FunThomas Nov 18 '20 at 11:28