Button to increment cell number

  • Hey all, i'm new here and new to VBA but have made my way into it, i've been asked something very simple at my work, that i havent been able to do, because i don't know the proper sintax of VBA, i need to make a button, that increments the number of a cell. I know this may sound dumb, but sometimes little things can get rough :thanx:

  • Re: Button to increment cell number


    dj,


    Place a button on the worksheet - makesure it is from the Controls toolbox not the Forms collection.


    Double click the button to activate the code pane, in between the buttons click event (this should appear by default) place the following:


    Code
    Sheets("sheet2").Range("a6").Value = Sheets("sheet2").Range("a6").Value + 1



    The end result looks like:


    Code
    Private Sub CommandButton1_Click()
    Sheets("sheet2").Range("a6").Value = Sheets("sheet2").Range("a6").Value + 1
    End Sub


    Regards
    Weasel

  • Re: Button to increment cell number


    Hey Weasel thnx for the help, it was just what i needed. Is there a place where i could get the syntaxes for VBA? i would like to experiment on my own, to see if i still remember something :)

  • Re: Button to increment cell number


    The internet is full of great websites that provide help with VBA - but dont go to far - you're already at the best.


    Check out some of the tips and tricks on the mothersite - here as well as posts on the board.


    Also have a look in the bookshop, there are some great learner resources there.


    Another good way to pick up syntax is record macros and examine the (inefficient but accurate) code generated, then play with it till it does what you want. This isn't possible 100% of the time but is great way to learn.


    Regards
    Weasel

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!