What's wrong with this code (r1c1 paste)

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

ActiveCell.FormulaR1C1 =
"=IF(AND((VALUE(YEAR($I6)&MONTH($I6))<=(VALUE(2004&N$5))),(VALUE(YEAR($J6)&MONTH($J6))>=VALUE(2004&N$5))),1,0)"
 
For starters, you've used FormulaR1C1, which requires the cell references to
be in R1C1 format. You've used A1 style references. In R1C1 notation, you need
to know the row number and column number of the active in order to convert
them. If the active cell is A1, $I6 is R[5]C9, N$5 is R5C[13]. The numbers
inside the brackets specify the offset from the active cells.

Rather than converting all of them, try using the Formula property instead
<g>.
 
You are using A1 notation and FormulaR1C1, try

ActiveCell.Formula = _
"=IF(AND((VALUE(YEAR($I6)&MONTH($I6))<=(VALUE(2004&N$5))),(VALUE(YEAR($J6)&M
ONTH($J6))>=VALUE(2004&N$5))),1,0)"
 
Hi Myrna
Rather than converting all of them, try using the Formula property instead
<g>.
Is this a way of converting R1C1 back to A1 notation quickly? I noticed the
grin.

TIA

Bob C.

---

Myrna Larson said:
For starters, you've used FormulaR1C1, which requires the cell references to
be in R1C1 format. You've used A1 style references. In R1C1 notation, you need
to know the row number and column number of the active in order to convert
them. If the active cell is A1, $I6 is R[5]C9, N$5 is R5C[13]. The numbers
inside the brackets specify the offset from the active cells.

Rather than converting all of them, try using the Formula property instead
<g>.


ActiveCell.FormulaR1C1 =
"=IF(AND((VALUE(YEAR($I6)&MONTH($I6))<=(VALUE(2004&N$5))),(VALUE(YEAR($J6)&MONTH($J6))>=VALUE(2004&N$5))),1,0)"
 
No. I meant that changing the function to Formula is much quicker than leaving
it as FormulaR1C1 and figuring out the R1C1 references.

To do the latter, you would stuff your existing formula into a string, then
use the Application.ConvertFormula method to convert it to R1C1



Hi Myrna
Rather than converting all of them, try using the Formula property instead
<g>.
Is this a way of converting R1C1 back to A1 notation quickly? I noticed the
grin.

TIA

Bob C.

---

Myrna Larson said:
For starters, you've used FormulaR1C1, which requires the cell references to
be in R1C1 format. You've used A1 style references. In R1C1 notation, you need
to know the row number and column number of the active in order to convert
them. If the active cell is A1, $I6 is R[5]C9, N$5 is R5C[13]. The numbers
inside the brackets specify the offset from the active cells.

Rather than converting all of them, try using the Formula property instead
<g>.


ActiveCell.FormulaR1C1 =
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top