0

I have a list of incoming inventory with part numbers and corresponding incoming amounts in one sheet and a comprehensive part list with current inventory amounts in another. I want to be able to run code that adds the incoming inventory amounts to the current inventory. So far, I am able to get the code to assign the new inventory value to a variable cur_inv but I cannot get it to push that new value to the correct cell. Here's the code:

Sub Test()
ActiveSheet.Range("A1").Select
Do Until IsEmpty(ActiveCell)

    lookfor = ActiveCell.Offset(0, 1).Value
    Set r = Sheets("Available Inventory").Range("Lookup")
    cur_inv = Application.WorksheetFunction.VLookup(lookfor, r, 2, False)
    new_inv = ActiveCell.Offset(0, 2).Value

    cur_inv = new_inv + cur_inv

    ActiveCell.Offset(1, 0).Select
Loop

End Sub
Dave
  • 4,328
  • 2
  • 24
  • 33
mdbarntz
  • 11
  • 2
  • 2
    Make sure you declare your variables. Also, learn to [avoid using .select](http://stackoverflow.com/questions/10714251/how-to-avoid-using-select-in-excel-vba-macros). – Kyle Jun 27 '16 at 14:24
  • Please provide some kind of example of what you would like to achieve. I think the question does not really give enough information to solve the exact issue you are facing. – ArBro Jun 27 '16 at 22:06

1 Answers1

0

You can do it by setting the value of the variable as a value for your cell like:

ActiveSheet.Range("Your Cell here").Value = new_inv
ArBro
  • 731
  • 5
  • 18
  • Thanks for your response! The problem is that the cell I want to assign the new value to will need to be found using something similar to a vlookup. Do you know how to do this? – mdbarntz Jun 27 '16 at 14:30