UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> mystery characters    
 
   
dday76
post Jul 18 2006, 01:11 PM
Post #1

UtterAccess Addict
Posts: 152
From: New York, NY



So I've got an excel workbook. I've got a module where I input the code below.

CODE
    Range("E1").Select
    ActiveCell.FormulaR1C1 = _
        "=IF(RC[13]>0,MIN(ROUNDDOWN(Control!N7/RC[16],0),RC[13]))"


I run the macro, and Lo and behold, praise the lord, a miracle occurs, and in my spreadsheet, I get things like this:

CODE
=IF(R3>0,MIN(ROUNDDOWN(Control!'N7'/U3,0),R3))


Now I'm totally ok with RC[] returning cell references, but getting 'N7' instead of N7 is breaking my reference. What is going on?

Jason
Go to the top of the page
 
+
norie
post Jul 18 2006, 01:18 PM
Post #2

UtterAccess VIP
Posts: 4,295



Jason

Your mixing R1C1 and A1 referencing when trying to create a R1C1 reference using the FormulaR1C1 property.

What should N7 be in R1C1 referencing?
Go to the top of the page
 
+
dday76
post Jul 18 2006, 04:12 PM
Post #3

UtterAccess Addict
Posts: 152
From: New York, NY



Ah yes. I guess I am.

I tried using the R1C1 reference, but it's supposed to be a nonchanging reference. Actually I would want it to be $N$7.

the thing is, this formula gets mass pasted, so the relative references are important as well. Can I get one absolute reference and one relative reference?


Jason
Go to the top of the page
 
+
dday76
post Jul 20 2006, 02:43 PM
Post #4

UtterAccess Addict
Posts: 152
From: New York, NY



So the solution I found was to declare a variable, set the variable equal to the absolute cell reference, and concatenate the variable into the FormulaR1C1 expression.

"=IF(RC[13]>0,MIN(ROUNDDOWN(" & NewVariable & "/RC[16],0),RC[13]))"
Go to the top of the page
 
+
norie
post Jul 20 2006, 03:00 PM
Post #5

UtterAccess VIP
Posts: 4,295



This worked for me.
CODE
Range("E1").FormulaR1C1 = "=IF(RC[13]>0,MIN(ROUNDDOWN(Control!R7C14/RC[16],0),RC[13]))"

I think the key to absolute/relative referencing in R1C1 notation is the [].

By the way the R in RC[13] is being treated as column R.(IMG:http://www.utteraccess.com/forum/style_emoticons/default/dazed.gif)
Go to the top of the page
 
+

Thank you for your support! Reply to this topicStart new topic

Jump To Forum:
 



RSS Go to Top  ·  Lo-Fi Version Time is now: 20th May 2013 - 03:38 AM