Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Macro to Increment a Cell's Value By 1

Sorry if this is a stupid question.

I would like to have a macro activated by a button. You
would select a cell (for example, with "2" in it), click
the button, and the value in the cell would be incremented
by 1 (in the example, it would now be "3"). Is is possible
to do, and can anyone tell me how to do it?

Thanks,

Dave
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Macro to Increment a Cell's Value By 1

Try this Dave

Sub test()
If IsNumeric(ActiveCell.Value) Then
ActiveCell.Value = ActiveCell.Value + 1
End If
End Sub


--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2002 SP-2)
www.rondebruin.nl



"Dave" wrote in message ...
Sorry if this is a stupid question.

I would like to have a macro activated by a button. You
would select a cell (for example, with "2" in it), click
the button, and the value in the cell would be incremented
by 1 (in the example, it would now be "3"). Is is possible
to do, and can anyone tell me how to do it?

Thanks,

Dave



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 620
Default Macro to Increment a Cell's Value By 1

Dave,

Public Sub Increment()
ActiveCell.Value = ActiveCell.Value + 1
End Sub


And here's some code to add a button to the formatting menu

Sub AddMenu()
Dim oCb As CommandBar
Dim oCtl As CommandBarButton

Set oCb = Application.CommandBars("Formatting")
With oCb
Set oCtl = .Controls.Add(Type:=msoControlButton, temporary:=True)
oCtl.Caption = "Increment"
oCtl.BeginGroup = True
oCtl.FaceId = 137
oCtl.OnAction = "Increment"
End With
End Sub
--

HTH

Bob Phillips

"Dave" wrote in message
...
Sorry if this is a stupid question.

I would like to have a macro activated by a button. You
would select a cell (for example, with "2" in it), click
the button, and the value in the cell would be incremented
by 1 (in the example, it would now be "3"). Is is possible
to do, and can anyone tell me how to do it?

Thanks,

Dave



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
Macro - How to increment cell reference by one row lau_ash[_2_] Excel Worksheet Functions 7 April 4th 23 02:17 PM
Using a cell's value in a macro command TomHull Excel Discussion (Misc queries) 2 November 20th 09 07:45 AM
Using macro recorder increment cell by one? Student2 Excel Discussion (Misc queries) 4 March 26th 09 05:05 PM
copy cell with macro and increment down each time RJJ Excel Worksheet Functions 6 May 9th 08 06:16 PM
Refering to Cell's Name in Macro LSB Excel Programming 5 August 8th 03 03:51 AM


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

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

About Us

"It's about Microsoft Excel"