View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
FSt1 FSt1 is offline
external usenet poster
 
Posts: 3,942
Default 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