Expected end of Statement

  • Thread starter FIRSTROUNDKO via OfficeKB.com
  • Start date
F

FIRSTROUNDKO via OfficeKB.com

Hi,

I am getting the error "Expected end of Statement" for the below code
Please can somebody help me fix this.


Sub insert()

Dim LastRow As Long
With ActiveSheet
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
..Range("D3:D" & LastRow).Formula = "=IF(OR(A3="CAR",A3="BUS",A3="TRAIN"),"X",
"")"
End With
End Sub

Thanks

Darren
 
A

Ardus Petus

You must double the " within double-quotes.

Sub insert()
Dim LastRow As Long
With ActiveSheet
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
.Range("D3:D" & LastRow).Formula = _
"=IF(OR(A3=""CAR"",A3=""BUS"",A3=""TRAIN""),""X"","""")"
End With
End Sub

HTH
 
M

MageeStringer

"=IF(OR(A3=""CAR"",A3=""BUS"",A3=""TRAIN""),""X"","""")"

requires double quotes
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top