"Type Mismatch" Error 13

tjak

Board Regular
Joined
Jan 2, 2003
Messages
117
I'm getting "Type Mismatch" with the following code. Can someone please help?

LastRow = Cells(Rows.count, 1).End(xlUp).Row

Sheets("Sheet1").Select
Range("d2:D" & LastRow).Select
ActiveCell.formular1c1 = "=If(g2>2500,""KIRSTEN"",If(A2<""L"",""JAN"",""LEEANN""))"
With Range("D2").Value = "=If(g2>2500,""KIRSTEN"",If(A2<""L"",""JAN"",""LEEANN""))"
Selection.AutoFill Destination:=Range("D2", Cells(LastRow, "D")), Type:=xlFillDefault
End With


On the actual spreadsheet, the formula above is placing an apostrophe before and after the G2 and A2 references and producing a #NAME error. When I remove the apostrophes, the #NAME disappears and the formula works.
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
This line
With Range("D2").Value = "=If(g2>2500,""KIRSTEN"",If(A2<""L"",""JAN"",""LEEANN""))"

Doesn't seem to make sense to me. Eliminate the with.

Range("D2").Value = "=If(g2>2500,""KIRSTEN"",If(A2<""L"",""JAN"",""LEEANN""))"
 
Upvote 0
also, if you are using references such as G1 and G2, you should use the Formula property, not FormulaR1C1 as you currently have.
 
Upvote 0

Forum statistics

Threads
1,224,811
Messages
6,181,082
Members
453,021
Latest member
Justyna P

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