+ Reply to Thread
Results 1 to 8 of 8

Adding a value to a cell(A1) and putting the resulting total back into A1

  1. #1
    Registered User
    Join Date
    02-24-2011
    Location
    Toronto
    MS-Off Ver
    Excel 2007
    Posts
    8

    Adding a value to a cell(A1) and putting the resulting total back into A1

    Hi all, first time here and I am looking for a little help with a small pet project of mine.

    Essentially what I am trying to accomplish is this:

    Please Login or Register  to view this content.
    What I want to happen is that a1 starts at a number (can be anything) and every time I hit F9(calculate) I want the random number in a2 to be added to the total in a1.

    So if a1 = 0
    Then I get a random number of 4 in A2
    I want A1 = 4 now
    Then I want to hit F9 again to get a number random number, say 3 this time and have A1 change to 7 and so on.

    Is this possible or should I just give up now?

    I have little to no experience in VBA but I learn fast so with a little guidance I should be good.

    Thanks!
    Last edited by Masrim; 02-25-2011 at 03:20 PM. Reason: solved

  2. #2
    Forum Expert Simon Lloyd's Avatar
    Join Date
    03-02-2004
    Location
    locked in the cage
    MS-Off Ver
    All the ones my homepage shows
    Posts
    3,161

    Re: Adding a value to a cell(A1) and putting the resulting total back into A1

    Well it will have to be VBA but you will have to make sure that your calculation is set to manual:
    1. Right Click sheet tab
    2. Choose "View Code"
    3. Paste in the below
    Please Login or Register  to view this content.
    Not all forums are the same - seek and you shall find

  3. #3
    Registered User
    Join Date
    02-24-2011
    Location
    Toronto
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: Adding a value to a cell(A1) and putting the resulting total back into A1

    Excellent so this will cycle every time I hit F9 then?

  4. #4
    Forum Expert Simon Lloyd's Avatar
    Join Date
    03-02-2004
    Location
    locked in the cage
    MS-Off Ver
    All the ones my homepage shows
    Posts
    3,161

    Re: Adding a value to a cell(A1) and putting the resulting total back into A1

    Yes as long as you have TOOLS>OPTIONS>CALCULATION set to manual then hitting F9 will cause the increase

  5. #5
    Registered User
    Join Date
    02-24-2011
    Location
    Toronto
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: Adding a value to a cell(A1) and putting the resulting total back into A1

    Excellent, thank you very much Simon!

  6. #6
    Registered User
    Join Date
    02-24-2011
    Location
    Toronto
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: Adding a value to a cell(A1) and putting the resulting total back into A1

    Well I have tried expanding on your bit of code there but I am having troubles with some if statements.

    Essentially I want to perform different actions based the result of the random number. This is what I have pieced together trying to extrapolate from your code.

    Please Login or Register  to view this content.
    I have also played around using a select case
    Please Login or Register  to view this content.
    However I do not seem to be able to use the cells. I have tried various things, tried to find it in the help and on google but could not find anything clear.

    So any help on this would be appreciated.

    Thanks!

  7. #7
    Forum Expert Simon Lloyd's Avatar
    Join Date
    03-02-2004
    Location
    locked in the cage
    MS-Off Ver
    All the ones my homepage shows
    Posts
    3,161

    Re: Adding a value to a cell(A1) and putting the resulting total back into A1

    I have no idea what you are trying to do or why you had 17 "#"'s in your code but here it is cut down for what i could tell was going on
    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    02-24-2011
    Location
    Toronto
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: Adding a value to a cell(A1) and putting the resulting total back into A1

    Hi Simon,

    The problem was all those #'s. lol

    Like I said I am pretty new to VBA, seems I saw them somewhere and thought you needed them as part of the code. Once I removed them everything worked perfectly.

    If you are truly curious the code is to run a craps table tallying place bets.
    I might expand it to handle more of the betting options if I have the time. but as it stands this works well.

    Thanks again for all your help!

+ 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