PDA

View Full Version : Subtract textbox value from cell value



MarceloTDK
01-18-2015, 08:24 AM
Hello,

I've been working on this worksheet and facing some problems! The worksheet consist of a sheet that contains a data base (Code, product, quantity). The idea is to use a userform that contains two text boxes and one command button: One for the product's code and one for the quantity that you want to subtract from the sheet that contains all the data and the command button that will perform the subtraction.


So when you put the code in the text box1 and a value text box 2, it would first search if the code inserted exists in the sheet (data base). If does, then it would subtract the value inserted in the text box 2 from the corresponding quantity value of the product's code. Below follows a example:

Code Product quantity

9888 Atmega 50
8585 Protoboard 30


If textbox1 = 9888, read the value of textbox2. And then when pressed the command button, subtract the value of textbox2 from the corresponding quantity of product's code inserted in textbox1:

textbox1 = 9888
textvox2 = 15


Code Product Quantity


9888 Atmega 15
8585 Protoboard 30


This code is quite simple and i've been trying to elaborate all sort of coding to get this to work but with no success so far...I hope you guys can give me some hints and suggestions.

Thank you very much for your support.

Marcelo

SamT
01-18-2015, 09:55 AM
Sub TextBox2_Change()
On Error GoTo NoFind

With Sheets("DATA").Columns(Code).Find(Textbox1, Blah, Blah, Blah).Offset(, 2)
.Value = .Value - TextBox2
End With

Exit Sub
NoFind:
MsgBox "Did not find" & TextBox1
End Sub