Hi,
This is like a puzzle for me. I am trying to create a vba code that replaces a value in a cell with an update which will add up the old value to the new value. The cell in question is determined by a VLookUp so we cant tell what it will always be. I am using a userform with a combobox, a textbox and a command button 'add'. Everything else looks fine except this replacement.
This how far I have gone. Can anyone please help point out what am missing?
This is like a puzzle for me. I am trying to create a vba code that replaces a value in a cell with an update which will add up the old value to the new value. The cell in question is determined by a VLookUp so we cant tell what it will always be. I am using a userform with a combobox, a textbox and a command button 'add'. Everything else looks fine except this replacement.
This how far I have gone. Can anyone please help point out what am missing?
Code:
Private Sub cmdAdd_Click()
Dim ustock As Integer, pstock As Integer
Dim cboPro As Variant
With Worksheets("Sheet5").Range("TS")
pstock = Application.WorksheetFunction.VLookup(Me.cboPro.Value, Worksheets("Sheet5").Range("TS"), 2, False)
End With
ustock = pstock + Val(txtsto)
'I need to replace the value of pstock on my table with an updated stock value ustock which is an addition of the value from a textbox on this userform
End Sub