a button to add 1 to a cell

R

Ron

I need to create a button that will ADD 1 to a cell everytime I click it.
Actually 3 bottons (1,5,10). I will need to repeat these buttons for 50
students to their total score. I don't know if this matters. I don't mind
creating buttons as long as they're easy to program.
Help Obe Wan
 
J

JBeaucaire

To keep from needing 150 macros, just use 3. Here are your macros, pu
them into your sheet first

Code
-------------------
Sub Add1(
Selection.Value = Selection.Value +
Bee
End Su

Sub Add5(
Selection.Value = Selection.Value +
Bee
End Su

Sub Add10(
Selection.Value = Selection.Value + 1
Bee
End Su

-------------------
Now turn on the Forms Toolbar, draw a button and select Add1 macro. Dra
another and select Add5, and the third uses Add10. Edit the text on th
buttons

Now, the buttons will add the values noted to the currently selecte
cell. If you don't like the "beeps" delete them, I thought the audibl
confirmation the macro ran and the number was added was a good thing i
this situation
 
R

Ron

I don't understand "put them into your sheet first"
I am using Access 2007 if that helps.
How do I "put" them?
Thanks again,
Ron
 
L

Luke M

I believe JBeaucaire meant the VBA sheet first. However, you just mentioned
that you are using Access, and this is the Excel newsgroup. Are you in the
right forum? If you meant Excel...

From spreadsheet, right click on sheet name, choose "view code". Paste
JBeaucaire's code there.
 
L

Lisa Cervantes

Hello... This is almost exactly what I am trying to do, I have the "add 1" macro as discribed above working for one selected cell...

But I am trying to add 1 to the individual values of multiple cells when the "add 1" macro is ran. Can the code be modified to add 1 to the individual values of a predetermined group of cells? In my case it would be B2:B173...

Thank you!!!
 
G

Gord

Sub add_1_to_range()
Dim rng As Range, ocell As Range
Set rng = Range("B2:B173")
For Each ocell In rng
If ocell.Value <> "" And Application.IsNumber(ocell.Value) Then
ocell.Value = ocell.Value + 1
End If
Next
End Sub


Gord Dibben Microsoft Excel MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top