Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Adding one to the current value in a cell

Hi,

I'm trying to set something up that enables me to press a button and
the numeric value in a cell will increase by one. I don't want this
cell to relate to another cell, just if, say, the value in the cell
was 1 and I pressed a key it would increase to 2 and if I pressed the
key again it would increase to 3 and so on...

Can anyone help me?

Mitch

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 78
Default Adding one to the current value in a cell

Hi, try the following code snippet, cells(1,1).value = cells(1,1).value+1.
This will increment the value at row 1 and column 1 by 1. Include this
snippet within the code that will be called when a button is pressed.

" wrote:

Hi,

I'm trying to set something up that enables me to press a button and
the numeric value in a cell will increase by one. I don't want this
cell to relate to another cell, just if, say, the value in the cell
was 1 and I pressed a key it would increase to 2 and if I pressed the
key again it would increase to 3 and so on...

Can anyone help me?

Mitch


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default Adding one to the current value in a cell

right click sheet tabview codeinsert this
Now, if you double click cell a5 or a6 the cell clicked will increase by
one. Is that what you want?

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
Boolean)
If Target.Address = "$A$5" Or Target.Address = "$A$6" Then
On Error GoTo fixit
Application.EnableEvents = False
If Target.Value = 0 Then oldvalue = 0
Target.Value = 1 * Target.Value + 1
oldvalue = Target.Value
fixit:
Application.EnableEvents = True
End If
Cancel = True
End Sub

--
Don Guillett
SalesAid Software

wrote in message
s.com...
Hi,

I'm trying to set something up that enables me to press a button and
the numeric value in a cell will increase by one. I don't want this
cell to relate to another cell, just if, say, the value in the cell
was 1 and I pressed a key it would increase to 2 and if I pressed the
key again it would increase to 3 and so on...

Can anyone help me?

Mitch



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Adding one to the current value in a cell

Hi again,

Thankyou both for your help that's great and has solved my problem,

Mitch

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default Adding one to the current value in a cell

Although you didn't say what you used, glad to help

--
Don Guillett
SalesAid Software

wrote in message
ups.com...
Hi again,

Thankyou both for your help that's great and has solved my problem,

Mitch



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
Date in cell keeps adding the current year. Excelsior731 Excel Discussion (Misc queries) 6 April 13th 09 05:51 PM
Adding a worksheet to a current workbook naschulte Excel Discussion (Misc queries) 7 June 28th 07 07:44 PM
Adding a worksheet to a current workbook naschulte Excel Discussion (Misc queries) 1 June 28th 07 05:26 PM
Adding to current cells Tom Excel Worksheet Functions 5 January 29th 07 01:39 AM
Adding current selection RICOUK Excel Programming 3 August 27th 05 10:31 PM


All times are GMT +1. The time now is 07:58 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"