Excel/How to enter a formula in an excel macro without using the string format
Expert: Douglas M. Smith - 7/9/2009
QuestionHi
I am trying to calculate polynomial coefficients in an excel macro. I can write
ActiveCell.FormulaR1C1 = "=INDEX(LINEST(R2C4:R1005C4,R2C6:R1005C6^{1,2,3,4,5,6}),1)"
but I want to specify the range rather than having to say "R2C4:R1005C4". I cant do it in this string format. Is there a way I can use Range() or Cells() to specify my range in the above equation? How can I do it?
One way I can think is to make the string programmatically but that doesn't sound like right.
Thanks in advance,
Kaushalya
AnswerHi Kaushalya,
Use ActiveCell.Formula instead of ActiveCell.FormulaR1C1 to enter a formula with cell references or range names.
Example:
ActiveCell.Formula = "=SUM(A1:A8)"
Doug Smith
Brainbench MVP for MS Excel
www.brainbench.com
www.abundant-solutions.com
About Excel
This topic answers questions related to Microsoft Excel spreadsheet (or workbook) stand-alone or Mircrosoft Office Excel including Excel 2003, Excel 2007, Office 2000, and Office XP. You can get Excel help on Excel formulas(or functions), Excell macros, charting in Excel, advanced features, and the general use of Excel. This does not provide a general Excel tutorial nor the basics of using a spreadsheet. It provides specific answers to using Microsoft Excel only. If you do not see your
Excel question answered in this area then please ask an Excel question here