Good evening! Been searching all over, and I’m afraid I’ve just got something completely backwards (I don’t know too much about Excel/VBA and and 99% sure I’m doing everything that most difficult way possible).
What I’m trying to do is find a value from another sheet, and change it.
For i = SORowStart To SORowEnd
'Grabbing this information PID and QTY from my main sheet.
ProductID = Range("B" & i).Value
ProductQty = Range("A" & i).Value
'I then need to match up PID on another sheet, and modify its Qty
If (Len(ProductID) > 0) Then
'Finding old quantity, successfully..but how do I change it??
OldQty = Application.WorksheetFunction.VLookup(ProductID, Worksheets("Inventory").Range("List_InventoryTable"), 4, False)
'MsgBox (ProductID & " - SELLING:" & ProductQty & "/" & OldQty)
'SO HERES MY PROBLEM LINE! ****************************
'I've tried with and without the "Set" keyword too.
'Set Application.WorksheetFunction.VLookup(ProductID, Worksheets("Inventory").Range("List_InventoryTable"), 4, False).Value = (OldQty - ProductQty)
End If
Next i
If anyone could point me in the right direction or tell me what keywords to search for, anything would be incredibly helpful…I’ve been stumped on this for hours now –_–
I’ve tried to find the address of the OldQty cell, but no success. It seems possible to do within the Excel Cell Formulas (using =ADDRESS and =MATCH (?)) but I haven’t a clue doing it inside VBA. Thanks for reading 🙂
It seen that the VLOOKUP function is returning a value not a range reference. I will give you an example using MATCH and INDEX function:
Check this page http://www.techonthenet.com/excel/formulas/vlookup.php