Matching values in 2 columns REFUSES to work correctly!

zookeepertx

Well-known Member
Joined
May 27, 2011
Messages
586
Office Version
  1. 365
Platform
  1. Windows
This is just infuriating me!

Within my macro is the following code:

Code:
For i = lr To 2 Step -1
    If InStr(Range("J" & i).Value, Range("K" & i).Value) Then
    Rows(i).Delete
    End If
Next i

As an example, for 3 of the rows, the value in J is
10100225056,10100225315,10100214598,10100212827,10100204778
10100225056,10100225315,10100214600,10100212827,10100157361,

while K is empty.
However, all of the lines are being deleted. I've tried everything I can think of to fix this with NO luck. I've spent a large part of the morning on this and am about to chuck the computer out the window.

Can someone please tell me what I'm doing wrong?? :banghead::banghead:

Thanks!

Jenny

<colgroup><col style="mso-width-source:userset;mso-width-alt:15506;width:318pt" width="424"> </colgroup><tbody>
[TD="width: 424"]10100225056,10100214600,10100212827,10100204778,10100204779,[/TD]

</tbody>
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
How about
Code:
Sub chk()
For i = LR To 2 Step -1
   If Len(Range("K" & i).Value) > 0 Then
      If InStr(Range("J" & i).Value, Range("K" & i).Value) Then
         Rows(i).Delete
      End If
   End If
Next i
End Sub
 
Upvote 0
Perfect! Thank you so much; you saved me! :pray:
My boss has been bugging me all day to get this finished)

Jenny
 
Upvote 0
Glad to help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,223,898
Messages
6,175,274
Members
452,628
Latest member
dd2

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top