VBA: Lookup A Value and Deduct A Value

Closed
JC - Oct 28, 2016 at 09:53 PM
TrowaD Posts 2921 Registration date Sunday September 12, 2010 Status Moderator Last seen December 27, 2022 - Nov 1, 2016 at 12:02 PM
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


Related:

1 response

TrowaD Posts 2921 Registration date Sunday September 12, 2010 Status Moderator Last seen December 27, 2022 552
Nov 1, 2016 at 12:02 PM
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
0