PDA

View Full Version : Need help with a Formula Creation



Poundland
02-26-2010, 06:14 AM
Guys,

I need some help please, I am trying to create a formula into a cell using assigned variables as row and column identifiers, but am at a loss on how to do it..

The code below is what I have created but this simply returns an error message when it is run..

ActiveCell.FormulaR1C1 = _
"=CORREL('Data Sheet'!R[& depn1 &]C[& depc1 &]:R[& depn1 + count &]C[& depc1 &],'Data Sheet'!R[& depn2 & &]C[& depc2 &]:R[& depr2 + count &]C[& depc2 &])"


depn1 refers to a row number
depc1 refers to a column number
depn2 refers to a row number
depc2 refers to a column number
count refers to a number

The general idea is that I want to create the formula in a cell and the formula will utilise data from the designated points..

What am I doing wrong?

Thanks for you help..

Bob Phillips
02-26-2010, 07:16 AM
Unttested, but try


ActiveCell.FormulaR1C1 = _
"=CORREL('Data Sheet'!R[" & depn1 & "]C[" & depc1 & "]:" & _
"R[" & depn1 + Count & "]C[" & depc1 & "]," & _
"'Data Sheet'!R[" & depn2 & "]C[" & depc2 & "]:" & _
"R[" & depr2 + Count & "]C[" & depc2 & "])"