Can a macro add a number? [Solved/Closed]

Report
-
Posts
4476
Registration date
Thursday January 28, 2010
Status
Contributor
Last seen
August 2, 2020
-
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 reply

Posts
4476
Registration date
Thursday January 28, 2010
Status
Contributor
Last seen
August 2, 2020
767
both are possible via macro
1
Thank you

A few words of thanks would be greatly appreciated. Add comment

CCM 2942 users have said thank you to us this month

Posts
4476
Registration date
Thursday January 28, 2010
Status
Contributor
Last seen
August 2, 2020
767
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
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 :)
Posts
4476
Registration date
Thursday January 28, 2010
Status
Contributor
Last seen
August 2, 2020
767
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
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 :)
Posts
4476
Registration date
Thursday January 28, 2010
Status
Contributor
Last seen
August 2, 2020
767
Make sure that you name routine different each time

Subscribe To Our Newsletter!

The Best of CCM in Your Inbox

Subscribe To Our Newsletter!