MrExcel Publishing
Your One Stop for Excel Tips & Solutions

Pop up box to add qty. to cell ? ? ?


Posted by Rick M on March 29, 2001 12:10 PM

I need to add quantities to cells.
Can I add a button to the sheet that is "add". when you click "add" a box pops up and allows a value to be entered and then "OK" add to the linked cell?
Ex : A1 current value = 100 , click "add" enter 50 then "OK" now cell A1 = 150. I would constantly be add vales to the cell as I continue to count.
thanks....


Posted by Dax on March 29, 2001 1:39 PM


You could use something like this:-

Add a command button to your sheet from the Control Toolbox. Double click it and add this code:-


Private Sub CommandButton1_Click()
Dim x As Long
x = InputBox("Enter number", "Number")
Range("a1").Value = Range("a1").Value + x
End Sub

Posted by Rick M on March 29, 2001 2:07 PM


DAX
I get a error when I hit "cancel"
Why?

Posted by Rick M on March 29, 2001 3:16 PM

I get Type Mismatch error on

Thanks DAX but , i get error when I select "cancel"? ? ? ? ? ? ?

Posted by Ivan Moala on March 29, 2001 5:00 PM

Re: I get Type Mismatch error on

Try

Private Sub CommandButton1_Click()
Dim x As Long
On Error Resume Next
x = InputBox("Enter number", "Number")
If x = 0 Then Exit Sub
Range("a1").Value = Range("a1").Value + x
End Sub


Ivan