Quantity to add up

james900

New member
Joined
Jul 23, 2015
Messages
1
Reaction score
0
Points
0
Hi there I'm new to Excel/VBA and struggling to get this to work. Basically I have a button which when pressed adds some text and a Value like this
Flowers 2


I need the button to add the value up so it will look like this if the button is pressed twice
Flowers 4


This is the code I have so far, but it adds the items like this, every time I click the button it adds another line.
Flowers 2
Flowers 2


My code:


Private Sub CommandButton1_Click()
ThisWorkbook.Sheets("ORDERS").Range("D30").End(xlUp).Offset(1, 0).Value = "2"
ThisWorkbook.Sheets("ORDERS").Range("C30").End(xlUp).Offset(1, 0).Value = " Flowers "
End Sub
 
This may do what you want:
Code:
Private Sub CommandButton1_Click()
Set mycell = ThisWorkbook.Sheets("ORDERS").Range("D30").End(xlUp)
mycell.Offset(1, 0).Value = mycell.Value + 2
mycell.Offset(1, -1).Value = " Flowers "
End Sub
 
Back
Top