• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Macros not working

ANKUSHRS1

Member
pls find flaw below code as it not working properly


Code:
Sub delete_unwanted_records()

Worksheets("Input").Activate

Dim c As Long
Dim i As Long




c = Application.WorksheetFunction.CountA(Worksheets("Input").Range("a:a"))



For i = 2 To c



Worksheets("Input").Range("ka" & i).Value = "=VLOOKUP(k" & i & ",Home!A:A,1,0)"


If IsError(Worksheets("Input").Range("ka" & i).Value) = True Then


Worksheets("Input").Rows(i & ":" & i).Delete Shift:=xlUp



End If

Next


Worksheets("Input").Rows("1:1").Delete Shift:=xlUp

Call filter_data


End Sub
 

Attachments

  • ank____formatpay.xlsm
    159 KB · Views: 3
Last edited by a moderator:
Hi ,

Without knowing what exactly you wish to do , it is difficult to find flaws in code.

The basic flaw is that when you are deleting rows , you should always start at the bottom of the range and work your way upwards towards the top of the range.

Thus , your For ... Next loop should be written as :

For i = c To 2 Step -1

Narayan
 
Back
Top