Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 56
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Loop through last cell/row of used range tkraju via OfficeKB.com Excel Discussion (Misc queries) 1 April 4th 09 04:45 PM
how to loop thru cell in 2 columns DMB Excel Programming 1 January 10th 06 03:51 PM
Advancing outer Loop Based on criteria of inner loop ExcelMonkey Excel Programming 1 August 15th 05 05:23 PM
loop through a cell. Vincent Jones Excel Programming 2 June 2nd 04 10:39 PM
get for loop to go on after blank cell? john_t_h[_12_] Excel Programming 3 January 15th 04 06:35 AM


All times are GMT +1. The time now is 09:27 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"