PDA

View Full Version : Solved: keeps crashing on this code



Djblois
04-18-2008, 06:52 AM
lngIndOverHead = Range("B67").Value
Range("B67").FormulaR1C1 = "=R[-66]C*.01" + lngIndOverHead

It keeps crashing on the second line of code. I don't know why? I have tried a few different ways. I need to replace the value in a field with a formula that relates to itself and that is why I used the variable, so I do not get a circular reference.

dominicb
04-18-2008, 08:13 AM
Good afternoon Djblois

You are trying to add the variable into the formula - but you need to add the value of the variable into the formula instead. Try this code :

lngIndOverHead = Range("B67").Value
Range("B67").FormulaR1C1 = "=R[-66]C*.01+" & lngIndOverHead

HTH

DominicB

Djblois
04-18-2008, 08:24 AM
Thank you very much. I tried with the ampersand but I did not know it also needed a plus sign in the quotes.