Hello,
What I want is a button that will add 1 to a number everytime it is pressed. Can you guys give me any help? Thanks
Hello,
What I want is a button that will add 1 to a number everytime it is pressed. Can you guys give me any help? Thanks
right click sheet tab>view code>insert this
Option Explicit
Dim oldvalue As Double
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address = "$A$5" Or Target.Address = "$B$5" Then
Application.EnableEvents = False
If Target.Value = 0 Then oldvalue = 0
Target.Value = 1 + oldvalue
oldvalue = Target.Value
Application.EnableEvents = True
End If
End Sub
Sub fixit()
Application.EnableEvents = True
End Sub
--
Don Guillett
SalesAid Software
[email protected]
"bxvang" <[email protected]> wrote in
message news:[email protected]...
>
> Hello,
>
> What I want is a button that will add 1 to a number everytime it is
> pressed. Can you guys give me any help? Thanks
>
>
> --
> bxvang
> ------------------------------------------------------------------------
> bxvang's Profile:
> http://www.excelforum.com/member.php...o&userid=35135
> View this thread: http://www.excelforum.com/showthread...hreadid=548932
>
Okay, so what that code does is...
2 cells A5 and B5
You click on either cell and it adds +1 to the previous number in the cell.
Is there a way to assign that code to a button? Thanks for your help. It is much appreciated.
Range("a1").value=range("a1").value + 1
Is that what you mean?
Jeff
"bxvang" <[email protected]> wrote in
message news:[email protected]...
>
> Okay, so what that code does is...
>
> 2 cells A5 and B5
>
> You click on either cell and it adds +1 to the previous number in the
> cell.
>
> Is there a way to assign that code to a button? Thanks for your help.
> It is much appreciated.
>
>
> --
> bxvang
> ------------------------------------------------------------------------
> bxvang's Profile:
> http://www.excelforum.com/member.php...o&userid=35135
> View this thread: http://www.excelforum.com/showthread...hreadid=548932
>
Yes, it works perfectly. Thanks!
For reference, here is another code that does the same thing.
Sub add_one()
With Activesheet.Range("A1")
.Value = .Value + 1
End With
End Sub
not without another dot
--
Don Guillett
SalesAid Software
[email protected]
"bxvang" <[email protected]> wrote in
message news:[email protected]...
>
> Yes, it works perfectly. Thanks!
>
> For reference, here is another code that does the same thing.
>
> Sub add_one()
>
> With Activesheet.Range("A1")
> Value = .Value + 1
> End With
>
> End Sub
>
>
> --
> bxvang
> ------------------------------------------------------------------------
> bxvang's Profile:
> http://www.excelforum.com/member.php...o&userid=35135
> View this thread: http://www.excelforum.com/showthread...hreadid=548932
>
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks