Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Loop through last cell/row of used range | Excel Discussion (Misc queries) | |||
how to loop thru cell in 2 columns | Excel Programming | |||
Advancing outer Loop Based on criteria of inner loop | Excel Programming | |||
loop through a cell. | Excel Programming | |||
get for loop to go on after blank cell? | Excel Programming |