VBA: Lookup A Value and Deduct A Value [Closed]

Report
-
Posts
2675
Registration date
Sunday September 12, 2010
Status
Moderator
Last seen
November 5, 2020
-
Hello!

I hope you guys are well! I oh so desperately need your help.

Here's what's going on...I'm gonna try to explain this as clearly as I can.

My RAW Data is from Columns A:L

When I enter a Unique ID on M1 and a number (let's say 10) on N1, I need the code to match the Unique ID (like vlookup would) on M1 to the Unique IDs on Column C and add the number of the corresponding data on Column J to the existing number... I hope that's clear...

For example:

C------------------J---------------M--------N
1| 1010------------84-------------1011------10
2| 1011------------72
3| 1012------------42

So in this case, the program will match the ID from M1 to C then add the 10 to 72 on J.

Does that make sense?

I hope you can help me.

Thank you in advance!
JC


1 reply

Posts
2675
Registration date
Sunday September 12, 2010
Status
Moderator
Last seen
November 5, 2020
448
Hi JC,

That actually does make sense!

Try the following code:
Sub RunMe()
Dim vFind As Range
Set vFind = Columns("C:C").Find(Range("M1"))
If vFind Is Nothing Then Exit Sub
Range("J" & vFind.Row).Value = Range("J" & vFind.Row).Value + Range("N1").Value
End Sub


Best regards,
Trowa

Subscribe To Our Newsletter!

The Best of CCM in Your Inbox

Subscribe To Our Newsletter!