Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Macro - How to increment cell reference by one row | Excel Worksheet Functions | |||
Using a cell's value in a macro command | Excel Discussion (Misc queries) | |||
Using macro recorder increment cell by one? | Excel Discussion (Misc queries) | |||
copy cell with macro and increment down each time | Excel Worksheet Functions | |||
Refering to Cell's Name in Macro | Excel Programming |