Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Enter formula in a macro

I would like to have a macro when clicked on any cell, would run a formula,
but I can't find any examples of how to do this.

The formula is always in the same column referencing the same columns. (I
know I could copy and paste, but the formulas are different for different
items and I want to write a macro for each.)

=round(col c - row whatever / 55.12, 0)

Thanks!


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 573
Default Enter formula in a macro


Annette wrote:
I would like to have a macro when clicked on any cell, would run a formula,
but I can't find any examples of how to do this.

The formula is always in the same column referencing the same columns. (I
know I could copy and paste, but the formulas are different for different
items and I want to write a macro for each.)

=round(col c - row whatever / 55.12, 0)

Thanks!


Assuming the formula goes into cell A1 in the active workbook and
sheet, and that the row is described by a defined variable called
"whatever", try:

range("A1").formula = "=round(c:" & whatever & "/55.12, 0)"

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Enter formula in a macro


ActiveCell.Formula = "=round(C" & activecell.row & "/ 55.12, 0)"

or
ActiveCell.FormulaR1C1 = "=Round(RC3/55.12,0)"

--
Regards,
Tom Ogilvy


"Annette" wrote:

I would like to have a macro when clicked on any cell, would run a formula,
but I can't find any examples of how to do this.

The formula is always in the same column referencing the same columns. (I
know I could copy and paste, but the formulas are different for different
items and I want to write a macro for each.)

=round(col c - row whatever / 55.12, 0)

Thanks!



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Enter formula in a macro

Great ... this is exactly what I needed! And written so I can understand it
.... both ways.


"Tom Ogilvy" wrote in message
...

ActiveCell.Formula = "=round(C" & activecell.row & "/ 55.12, 0)"

or
ActiveCell.FormulaR1C1 = "=Round(RC3/55.12,0)"

--
Regards,
Tom Ogilvy


"Annette" wrote:

I would like to have a macro when clicked on any cell, would run a
formula,
but I can't find any examples of how to do this.

The formula is always in the same column referencing the same columns.
(I
know I could copy and paste, but the formulas are different for different
items and I want to write a macro for each.)

=round(col c - row whatever / 55.12, 0)

Thanks!





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
Using a macro to enter a formula Tami Excel Worksheet Functions 4 September 24th 09 11:47 AM
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
Can you enter a formula in a cell to run a macro? Nevaeh Excel Worksheet Functions 2 February 14th 05 11:51 PM
Macro to enter formula with text bambam77[_3_] Excel Programming 5 January 2nd 04 01:56 AM


All times are GMT +1. The time now is 04:01 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"