No matter what I do I still can't get my head around variables and formulas.
I am trying to reference Row -117 by using a positive variable value.
The variable LR = 100 in this example, any help would be appreciated.
The top code is the straight formula.
.FormulaR1C1 = "=COUNTIF( R[-117]C:R[-1]C,""Yes"")".FormulaR1C1 = "=COUNTIF( R[" & -LR - 17 & "]C:R[-1]C,""Yes"")"
Last edited by JapanDave; 01-24-2012 at 06:28 AM.
If you are happy with the answer, please click the Star icon in the below left hand corner.
Good sites to start learning.
snb's VBA Help Files
Jerry Beaucaires Excel Assistant
J & R Excel Consultancy Services
How to post code correctly: Correct Code Posting
and what seems to be the problem? What cell are you trying to enter this formula into?
Your second example works fine for me ...
Microsoft MVP - Excel
Entia non sunt multiplicanda sine necessitate
Hey shg, the second example runs fine, but it does not give the row offset value of -117, it gives me a value of -51???
Edit: I am placing the formula in Row 135 to count values from row 17 to 134.
Last edited by JapanDave; 01-23-2012 at 05:01 PM.
If you are happy with the answer, please click the Star icon in the below left hand corner.
Good sites to start learning.
snb's VBA Help Files
Jerry Beaucaires Excel Assistant
J & R Excel Consultancy Services
How to post code correctly: Correct Code Posting
It is in my last post.
If you are happy with the answer, please click the Star icon in the below left hand corner.
Good sites to start learning.
snb's VBA Help Files
Jerry Beaucaires Excel Assistant
J & R Excel Consultancy Services
How to post code correctly: Correct Code Posting
Then LR doesn't equal 100 when the line of code is executed - can you place a breakpoint on this line and run the code and then see what value LR is when this line is executed?
The way I solve problems like this is to set a breakpoint at the line of interest, then copy the string to the Immediate window:
Press Enter, and I saw:? "=COUNTIF( R[" & -LR - 17 & "]C:R[-1]C,""Yes"")"
... as expected. As I said, it worked fine for me, Dave. Want to post a simple workbook with an example that fails?=COUNTIF( R[-117]C:R[-1]C,"Yes")
Microsoft MVP - Excel
Entia non sunt multiplicanda sine necessitate
shg & Firefly, your right it does work, my math skills don't however. Firefly, the moment I read your post I new a few lines ahead of this line that I changed the LR variable value.
Ahh, I have at this piece of code too long.
@ shg, thanks for the tip on the Immediate window, I would never have thought to use that.
Thanks guys.
Dave
If you are happy with the answer, please click the Star icon in the below left hand corner.
Good sites to start learning.
snb's VBA Help Files
Jerry Beaucaires Excel Assistant
J & R Excel Consultancy Services
How to post code correctly: Correct Code Posting
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks