SYNTAX ERROR on cells.Formula

jarvisaurus

Board Regular
Joined
Nov 26, 2010
Messages
52
I am getting a syntax error on the following line:

Code:
cells(i, "AI").Formula = "=(4917.56 * cells(i,"X").value + 424) * 0.93"

I had .value before but I need to show the actual formula. The cells(i,"X").Value should be the value of the corresponding row, column.

Any help is greatly appreciated.

Thanks
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
Do you want to include the address or value of Cells(i, "X")?

Or do you actually want to put the text cells(i, "X").value in the formula?
 
Upvote 0
Say i = 5 and the value in X5 is 20

If you want AI5's formula to be =(4917.56 *20+ 424) * 0.93, use

Code:
Cells(i, "AI").Formula = "=(4917.56 *" & Cells(i, "X").Value & "+ 424) * 0.93"

If instead you want AI5's formula to be =(4917.56 * X5+ 424) * 0.93, use
Code:
Cells(i, "AI").Formula = "=(4917.56 * X" & i & "+ 424) * 0.93"

Just depends on whether you want the hardcoded value from X5 or the reference to X5 in your formula.
 
Upvote 0

Forum statistics

Threads
1,224,520
Messages
6,179,267
Members
452,902
Latest member
Knuddeluff

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