Results 1 to 2 of 2

Thread: Quantity to add up

  1. #1

    Quantity to add up



    Register for a FREE account, and/
    or Log in to avoid these ads!

    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

  2. #2
    Super Moderator p45cal's Avatar
    Join Date
    Dec 2012
    Posts
    1,786
    Articles
    0
    Excel Version
    365
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •