Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to use ActiveCell.FormulaR1C1 1

Status
Not open for further replies.

Louise99

Technical User
Sep 13, 2004
70
US
I wrote a macro in 97 to copy a simple formula down from the top cell to the bottom (ActiveCell.FormulaR1C1 = "=RC[-1]-RC[-5]"). Now, I find that I need to add an "if" statement. If the RC[-1] is less than zero, then I want "na" in the formula column. So, I thought that I could just use the statement ActiveCell.FormulaR1C1 = "if (RC[-1]>0,RC[-1]-RC[-5],na)". That didn't work so well! I need help using ActiveCell with a formula. Any help appreciated greatly!!!

Peace,
krfb :cool:
 
Hi,

I never liked abusing myself. So I GREATLY prefer A1 notation to R1C1.

But here goes...
Code:
ActiveCell.FormulaR1C1 = "=if(RC[-1]>0,RC[-1]-RC[-5],NA())"

Skip,
[sub]
[glasses] [red]Be advised:[/red] It's been reported that a wee psychic is roaming the countryside.
Small Medium @ Large! [tongue][/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top