View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
davegb davegb is offline
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)"