2
votes

I have the following code, which gives me the Compile error: "Expected: End of Statement" in the Subject line of code after the "Inc" Range.

This code is part of a module which opens MS Outlook email and enters data from specific cells in the data sheet (generated from a Userform) in to the Subject field of the email.

The code:

'This bit tells it where to send the email to, what the subject line is etc
    .to = "[email protected]"
    .CC = "[email protected]"
    .BCC = ""
    .Subject = "Inc" Range("H6").Value & " " & Range("G12").Value & " - " & Range("G14").Value & " " & Range("H8").Value
    .HTMLBody = RangetoHTML(rng)
    .Display

   End With
   On Error GoTo 0

Is this sufficient information?

1

1 Answers

2
votes

Can you check if it's because is missing the "&" operator

.Subject = "Inc"  Range("H6").Value & " " & Range("G12").Value & " - " & Range("G14").Value & " " & Range("H8").Value

Should be

.Subject = "Inc" & Range("H6").Value & " " & Range("G12").Value & " - " & Range("G14").Value & " " & Range("H8").Value