Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
How do I write a macro to increase the value of any cell by 1?
I am trying to create a macro to increase the value of any cell by a
constant, e.g., the number one. The VBA below keeps returning 4 even when applied to a cell with, say 8 in it. I'd like the macro to return 9 in that case. Sub Macro1() ' ' Macro1 Macro ' Macro recorded 6/6/2008 by Robert G. Wood ' ' Keyboard Shortcut: Ctrl+m ' ActiveCell.FormulaR1C1 = "=1+3" ActiveCell.Offset(1, 0).Range("A1").Select End Sub |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
How do I write a macro to increase the value of any cell by 1?
hi
this is because your recorded macro is putting the same formula in all cells. i don't think you want that so try this... Sub Macro1() ' ' Macro1 Macro ' Macro recorded 6/6/2008 by Robert G. Wood ' ' Keyboard Shortcut: Ctrl+m ' ActiveCell.Value = ActiveCell.Value + 1 ActiveCell.Offset(1, 0).Range("A1").Select End Sub regards FSt1 "Westwolf" wrote: I am trying to create a macro to increase the value of any cell by a constant, e.g., the number one. The VBA below keeps returning 4 even when applied to a cell with, say 8 in it. I'd like the macro to return 9 in that case. Sub Macro1() ' ' Macro1 Macro ' Macro recorded 6/6/2008 by Robert G. Wood ' ' Keyboard Shortcut: Ctrl+m ' ActiveCell.FormulaR1C1 = "=1+3" ActiveCell.Offset(1, 0).Range("A1").Select End Sub |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
How do I write a macro to increase the value of any cell by 1?
Sub Macro1()
ActiveCell.Value = ActiveCell.Value + 1 End Sub -- --- HTH Bob (there's no email, no snail mail, but somewhere should be gmail in my addy) "Westwolf" wrote in message ... I am trying to create a macro to increase the value of any cell by a constant, e.g., the number one. The VBA below keeps returning 4 even when applied to a cell with, say 8 in it. I'd like the macro to return 9 in that case. Sub Macro1() ' ' Macro1 Macro ' Macro recorded 6/6/2008 by Robert G. Wood ' ' Keyboard Shortcut: Ctrl+m ' ActiveCell.FormulaR1C1 = "=1+3" ActiveCell.Offset(1, 0).Range("A1").Select End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Create Macro to Increase Cell Reference | Excel Discussion (Misc queries) | |||
Number in cell increase with increase in font size. | Excel Discussion (Misc queries) | |||
Macro to increase cell number by 1 at a time | Excel Programming | |||
is it possible to execute write to the fields in another .xsl form a macro in another .xsl? e.g. some way to load another .xsl into an .xsl macro and write to its data? | Excel Worksheet Functions | |||
Question: Cell formula or macro to write result of one cell to another cell | Excel Programming |