Formula's with variables

Bernieg

Board Regular
Joined
Jan 1, 2009
Messages
146
Office Version
  1. 365
Platform
  1. Windows
Hi i would like to use global variables in formula's, should i be using Offset

VBA Code:
'Cells(r, 9).value= "5.41"
Imrav = 5.11115
Imrdev = 0.0264498
Datapoints = 1435
Binwidth = "0.01"

 ' THIS WORKS
Cells(r, 10).FormulaR1C1 = "=NORM.DIST(RC[-1],R10C[-6],R9C[-6],FALSE)*R8C[-6]*R5C[-6]"

'This doesn't
'Cells(r, 10).FormulaR1C1 = "=NORM.DIST(RC[-1],Imrav,imrdev,FALSE)*Datapoints*binwidth"

Thanks in advance

Bernie
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
How about this?

VBA Code:
Sub GV()
Imrav = 5.11115
imrdev = 0.0264498
Datapoints = 1435
binwidth = "0.01"

Cells(r, 10).FormulaR1C1 = "=NORM.DIST(RC[-1]," & Imrav & "," & imrdev & ",FALSE)*" & Datapoints & "*" & binwidth
End Sub
 
Upvote 1
Solution
How about this?

VBA Code:
Sub GV()
Imrav = 5.11115
imrdev = 0.0264498
Datapoints = 1435
binwidth = "0.01"

Cells(r, 10).FormulaR1C1 = "=NORM.DIST(RC[-1]," & Imrav & "," & imrdev & ",FALSE)*" & Datapoints & "*" & binwidth
End Sub
Thank you it worked a treat
 
Upvote 0

Forum statistics

Threads
1,215,443
Messages
6,124,890
Members
449,194
Latest member
JayEggleton

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top