Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 123
Default Using a macro to enter a formula

i'm trying to writ a macro that enters in a formula in a cell.

Scenario:
Assume my cursor is in row 8
I want to put a formula of "=O$9" in cell M9

Here's what i've got so far (but its not working)

dim x as integer
lr=activecell.row 'tells me what row i'm on
x=lr+1 'adds 1 to row number
cells(x,13).select 'move my cursor to column M of row x
ActiveCell.FormulaR1C1 = "=+RxC[2]" 'put the O$x formula in

thanks in advance for any assistance.
tami




  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 8,520
Default Using a macro to enter a formula

Hi Tami

Try the below

Dim x As Integer
lr = ActiveCell.Row 'tells me what row i'm on
x = lr + 1 'adds 1 to row number
Cells(x, 13).Formula = "=O$9" 'put the O$x formula in

If this post helps click Yes
---------------
Jacob Skaria


"Tami" wrote:

i'm trying to writ a macro that enters in a formula in a cell.

Scenario:
Assume my cursor is in row 8
I want to put a formula of "=O$9" in cell M9

Here's what i've got so far (but its not working)

dim x as integer
lr=activecell.row 'tells me what row i'm on
x=lr+1 'adds 1 to row number
cells(x,13).select 'move my cursor to column M of row x
ActiveCell.FormulaR1C1 = "=+RxC[2]" 'put the O$x formula in

thanks in advance for any assistance.
tami




  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 8,520
Default Using a macro to enter a formula

Oops...correction

Dim x As Integer
lr = ActiveCell.Row 'tells me what row i'm on
x = lr + 1 'adds 1 to row number
Cells(x, 13).Formula = "=O$" & x 'put the O$x formula in

If this post helps click Yes
---------------
Jacob Skaria


"Tami" wrote:

i'm trying to writ a macro that enters in a formula in a cell.

Scenario:
Assume my cursor is in row 8
I want to put a formula of "=O$9" in cell M9

Here's what i've got so far (but its not working)

dim x as integer
lr=activecell.row 'tells me what row i'm on
x=lr+1 'adds 1 to row number
cells(x,13).select 'move my cursor to column M of row x
ActiveCell.FormulaR1C1 = "=+RxC[2]" 'put the O$x formula in

thanks in advance for any assistance.
tami




  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3,440
Default Using a macro to enter a formula

ActiveCell.FormulaR1C1 = "=R" & x & "C[2]"

or

ActiveCell.FormulaR1C1 = "=RC[2]", which means "this row", 2 columns to the
right

--
Kind regards,

Niek Otten
Microsoft MVP - Excel

"Tami" wrote in message
...
i'm trying to writ a macro that enters in a formula in a cell.

Scenario:
Assume my cursor is in row 8
I want to put a formula of "=O$9" in cell M9

Here's what i've got so far (but its not working)

dim x as integer
lr=activecell.row 'tells me what row i'm on
x=lr+1 'adds 1 to row number
cells(x,13).select 'move my cursor to column M of row x
ActiveCell.FormulaR1C1 = "=+RxC[2]" 'put the O$x formula in

thanks in advance for any assistance.
tami





  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 8,520
Default Using a macro to enter a formula

Thanks Niek. I realise; I missed the query all together..

"Niek Otten" wrote:

ActiveCell.FormulaR1C1 = "=R" & x & "C[2]"

or

ActiveCell.FormulaR1C1 = "=RC[2]", which means "this row", 2 columns to the
right

--
Kind regards,

Niek Otten
Microsoft MVP - Excel

"Tami" wrote in message
...
i'm trying to writ a macro that enters in a formula in a cell.

Scenario:
Assume my cursor is in row 8
I want to put a formula of "=O$9" in cell M9

Here's what i've got so far (but its not working)

dim x as integer
lr=activecell.row 'tells me what row i'm on
x=lr+1 'adds 1 to row number
cells(x,13).select 'move my cursor to column M of row x
ActiveCell.FormulaR1C1 = "=+RxC[2]" 'put the O$x formula in

thanks in advance for any assistance.
tami







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 to select cells in column enter data then press enter NP New Users to Excel 1 February 20th 08 04:21 PM
Enter Static Date with a formula or macro Jason Southco Excel Discussion (Misc queries) 3 March 14th 06 07:46 PM
What does hitting Ctrl + Shift + Enter to enter a formula do??? Help a n00b out. qwopzxnm Excel Worksheet Functions 2 October 20th 05 09:06 PM
Make macro run when I hit the enter key Tommy Excel Discussion (Misc queries) 1 May 16th 05 12:53 AM
Can you enter a formula in a cell to run a macro? Nevaeh Excel Worksheet Functions 2 February 14th 05 11:51 PM


All times are GMT +1. The time now is 12:37 PM.

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"