Changin Number in cell on click of button

K

K

Hi all, How can i change number in cell A1 when ever i click command
button. for example i want macro that when i click on button it
should put 1 in cell A1 and when i click on button again it should put
2 in cell A1 and like this it should go till 10. I know i can achive
this from Spin button control and Scroll Bar control in excel but i
want it with command button by macro. Please can any friend can help
 
R

ryguy7272

Sub Cells_Loop()
Dim i As Range
For Each i In Range("A1") 'or whatever your range is
i.Value = i.Value + 1 'or whatever your code is
Next i
End Sub

HTH,
Ryan---
 
G

Gary''s Student

Sub Macro1()
ActiveSheet.Buttons.Add(141.75, 130.5, 89.25, 39).Select
Selection.OnAction = "BumpIt"
End Sub


Sub BumpIt()
With Range("A1")
If .Value < 11 Then
.Value = .Value + 1
End If
End With
End Sub

Paste both macros in a standard module. Then run Macro1 - it will create
the button and assign it to BumpIt
 

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