+ Reply to Thread
Results 1 to 4 of 4

VBA Code to add numbers when a button is clicked

Hybrid View

ISUCyclones VBA Code to add numbers when... 06-14-2012, 12:08 PM
tigeravatar Re: VBA Code to add numbers... 06-14-2012, 12:16 PM
ISUCyclones Re: VBA Code to add numbers... 06-14-2012, 12:24 PM
SirRyanGiggs Re: VBA Code to add numbers... 06-14-2012, 12:25 PM
  1. #1
    Registered User
    Join Date
    06-14-2012
    Location
    Ames, Iowa
    MS-Off Ver
    Excel 2010
    Posts
    50

    VBA Code to add numbers when a button is clicked

    I am not very good with writing VBA code so I'm looking for some help.

    I want to have a button in an Excel document (using a Macros) that when the user clicks the button, it adds 6 to a certain cell (F5). Then each time it is clicked, it keeps a running total.

    Is there any simple code that can do this for me?
    Thanks for your help!

  2. #2
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: VBA Code to add numbers when a button is clicked

    ISUCyclones,

    Welcome to the forum!
    Something like this should work for you:
    Sub Macro1()
        
        Range("F5").Value = Range("F5").Value + 6
        
    End Sub
    Hope that helps,
    ~tigeravatar

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  3. #3
    Registered User
    Join Date
    06-14-2012
    Location
    Ames, Iowa
    MS-Off Ver
    Excel 2010
    Posts
    50

    Re: VBA Code to add numbers when a button is clicked

    That works perfect for what I need. Thanks for your help Tigeravatar!

  4. #4
    Registered User
    Join Date
    05-08-2012
    Location
    Manchester
    MS-Off Ver
    Excel 2010
    Posts
    36

    Re: VBA Code to add numbers when a button is clicked

    This should work and to add a keyboard shortcut to your macro go to options enter your shortcut then click ok.

    Sub adding()
    Dim x As Integer
    x = Cells(5, 6).Value + 6
    Cells(5, 6).Value = x
    End Sub
    Any time you click that shortcut it should repeat the operation

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1