Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Incrementing a cell


Hi,

I've created a button on Excel that should add "1" to a particular cell
each time it is clicked. This should be very easy, but I'm struggling!

I've got the following code:

Private Sub CommandButton1_Click()
Sheets("Week 1").Range("B3") = + 1
End Sub

but this changes to:

Private Sub CommandButton1_Click()
Sheets("Week 1").Range("B3") = 1
End Sub

after the code window is closed. Obviously there is something wrong
with the syntax.

Please help. Thanks in advance.

Anar


--
anar_baku
------------------------------------------------------------------------
anar_baku's Profile: http://www.excelforum.com/member.php...o&userid=18259
View this thread: http://www.excelforum.com/showthread...hreadid=392094

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 114
Default Incrementing a cell

Or:

With Sheets("Week 1").Range("B3")
.Value = .Value + 1
End With

If the code is to be executed on the active sheet you can use:

With Range("B3")
.Value = .Value + 1
End With

Regards

Paul Martin
Melbourne, Australia

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
Incrementing cell addresses LaRana! Excel Worksheet Functions 1 March 1st 08 04:19 AM
Incrementing cell reference Paul Mugleston[_2_] Excel Discussion (Misc queries) 1 January 10th 08 04:06 PM
incrementing mm/yy based on value in other cell George Excel Worksheet Functions 2 March 1st 06 03:41 AM
Incrementing a cell Kaak[_30_] Excel Programming 0 August 2nd 05 12:17 PM
Incrementing Cell Numbers Lance W. Grimes Excel Discussion (Misc queries) 1 March 8th 05 07:51 PM


All times are GMT +1. The time now is 08:57 PM.

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"