Can a macro add a number?

Solved/Closed
Giorgio.usa - 12 May 2010 à 08:54
rizvisa1 Posts 4478 Registration date Thursday 28 January 2010 Status Contributor Last seen 5 May 2022 - 13 May 2010 à 10:14
I am working on a excel project where I will be able to click a button and the result would be a number added on another cell. For example, counting a products sale, if I have sold 5 I click that button 5 times and the result cell would have a +5 number. Is that possible? Anybody can help me with this? Another way could be to digit the number 5 on a cell and this will be added on the result cell, this can be an option too.
Thank you very much in advance :)

1 response

rizvisa1 Posts 4478 Registration date Thursday 28 January 2010 Status Contributor Last seen 5 May 2022 766
12 May 2010 à 09:13
both are possible via macro
giorgio.usa
12 May 2010 à 09:45
Funny answer :) Can you also tell me how?
Thanks.
rizvisa1 Posts 4478 Registration date Thursday 28 January 2010 Status Contributor Last seen 5 May 2022 766
12 May 2010 à 10:05
Ah glad you found it amusing :p~~. It was not intended.

Best would be have the clicks. To do that

1. Press ALT + F11 to start VBE
2. Click on Insert and add a new module
3. Paste the code below


Sub myButton()

Range("A1") = Range("A1") + 1

End Sub

4. Now on you sheet add the button and assign it the macro
giorgio.usa
13 May 2010 à 07:57
It worked! Yayy, thanks rizvisa1. I also found the way to add another macro, since they will be many buttons. I add the same code with different cell #s after the End Sub, is this the right way? Now I only have to find the way how to create a button :)
rizvisa1 Posts 4478 Registration date Thursday 28 January 2010 Status Contributor Last seen 5 May 2022 766
13 May 2010 à 08:17
What version of excel you are going to use for this ? Why not use help to find out how to add button. Basically its on toolbox
giorgio.usa
13 May 2010 à 10:02
Thanks again, I found out how to make a button with text inside. Now I have to repeat the macro command to different cells and same with buttons, and it should work out good. Thanks for your help :)