AllExperts > Excel 
Search      
Excel
Volunteer
Answers to thousands of questions
 Home · More Excel Questions · Answer Library  · Encyclopedia ·
More Excel Answers
Question Library

Ask a question about Excel
Volunteer
Experts of the Month
Expert Login

Awards

About Us
Tell friends
Link to Us
Disclaimer

 
 
 
 
About Douglas M. Smith
Expertise
I specialize in solving formula, feature and structure related problems. I know many tricks to help make your spreadsheets and processing more efficient.

Experience
Brainbench MVP for MS Excel
Past/Present clients
Gannett, Fannie Mae, Pepsi, Nortel, Procter & Gamble, BellSouth, Blue Cross Blue Shield of NC, NC Central University, GlaxoSmithKline, Maintenance Excellence Institute, AAI Pharmaceuticals, Blue Cross Blue Shield of SC, Brainbench.com

 
   

You are here:  Experts > Computing/Technology > Microsoft Software > Excel > How to enter a formula in an excel macro without using the string format

Excel - How to enter a formula in an excel macro without using the string format


Expert: Douglas M. Smith - 7/9/2009

Question
Hi

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

Answer
Hi 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

Add to this Answer   Ask a Question


 
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
User Agreement | Privacy Policy | Kids' Privacy Policy | Help
Copyright  © 2008 About, Inc. AllExperts, AllExperts.com, and About.com are registered trademarks of About, Inc. All rights reserved.