![]() |
Loop to add +1 in cell?
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 |
Loop to add +1 in cell?
right click sheet tabview codeinsert 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 "bxvang" wrote in message ... 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 |
Loop to add +1 in cell?
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 |
Loop to add +1 in cell?
Range("a1").value=range("a1").value + 1
Is that what you mean? Jeff "bxvang" wrote in message ... 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 |
Loop to add +1 in cell?
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 Su -- bxvan ----------------------------------------------------------------------- bxvang's Profile: http://www.excelforum.com/member.php...fo&userid=3513 View this thread: http://www.excelforum.com/showthread.php?threadid=54893 |
All times are GMT +1. The time now is 02:07 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com