Syntax Error

clynch28

New Member
Joined
Sep 21, 2017
Messages
19
I am trying to write code to insert this formula into a cell but it is coming up with an error box saying that it is expecting an ending. Can anyone help?

Cells(1, 8).Value = "Letter Grade"
Cells(2, 8).Activate
ActiveCell.Formula = "=IF($G2>=90,"A",IF(90>$G2>=80,"B",IF(80>$G2>=70,"C",IF(70>$G2>=60,"D","F"))))"
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
There's no need to select the cell first, but your problem is that VBA uses quotes to indicate the start and end of strings, so to include them, you need to enclose the quotes in quotes like this:

Code:
Cells(2, 8).Formula = "=IF($G2>=90,""A"",IF(90>$G2>=80,""B"",IF(80>$G2>=70,""C"",IF(70>$G2>=60,""D"",""F""))))"
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,904
Messages
6,175,295
Members
452,632
Latest member
jladair

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