Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default 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
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
Create Macro to Increase Cell Reference Darkh0st Excel Discussion (Misc queries) 3 September 24th 10 11:12 AM
Number in cell increase with increase in font size. Value increases with increase in font.[_2_] Excel Discussion (Misc queries) 2 August 9th 07 01:58 PM
Macro to increase cell number by 1 at a time felipe Excel Programming 6 August 27th 05 08:57 PM
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? Daniel Excel Worksheet Functions 1 June 23rd 05 11:38 PM
Question: Cell formula or macro to write result of one cell to another cell Frederik Romanov Excel Programming 1 July 8th 03 03:03 PM


All times are GMT +1. The time now is 08:21 AM.

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"