syntax error

gmazza76

Well-known Member
Joined
Mar 19, 2011
Messages
771
Office Version
  1. 365
Platform
  1. Windows
Good Afternoon,

I am having an issue with some code that a friend has given me and i am stuck with the error i get when i run it.

I get the following error

Compile Error : Syntax Error on the following line

Rich (BB code):
Dim MyWB As Workbook
Dim MySht As Worksheet
Dim MyManager As String
Dim MyAdvocate As String
Dim MyYourName As String
Dim MyProcessNumber As String 'Depending if the number has characters or is purely numeric
Dim MyProcessReason As String
 
Set MyWB = ActiveWorkbook
    If Cells(4, 4) = “” Then
            Msgbox “Please Enter The Manager Name”,vbokonly,“Missing Manager”
    Else
            MyManager = Cells(4, 4)
    End If
 
    If Cells(4, 6) = “” Then
            Msgbox “Please Enter The Advocate Name”, vbokonly, “Missing Advocate”
    Else
           MyAdvocate = Cells(4, 6)
    End If
    If Cells(4, 8) = “” Then
            Msgbox “Please Enter Your Name”, vbokonly, “Missing Your Name”
    Else
            MyYourName = Cells(4, 8)
Many Thanks
Gavin
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
You seem to have the wrong character for quotation marks throughout. Try like this

Code:
MsgBox "Please Enter The Manager Name", vbOKOnly, "Missing Manager"
 
Upvote 0
Gavin

All your quotes seem to be wrong, they should be " not “.

That can happen sometimes if you copied the code from somewhere else.

Just find and replace.

PS For some reason VBA thinks “” is a variable.:eek:

You'll still need to change them anyway.
 
Upvote 0
Many Thanks All,

I have replaced them and they seem ok.

Norie, sorry but what do you mean a variable??
 
Upvote 0
Well for this I mean you can declare “” as a variable and use it as one like this.
Code:
Option Explicit
 
Sub test()
 
Dim “”
 
    “” = "Something"
 
    MsgBox “”
 
End Sub
Which is something you definitely shouldn't do.:)
 
Upvote 0
Sorry Norie,

When you say this definetly shouldnt be done is there any specific reason why?

I am using 1 sheet as a template to complete Questions.
My submit button is picking up the manager name and then copying the info into there sheet in the workbook.

What way should i be doing this?

Cheers
 
Upvote 0
Gavin

I was only talking about using “” as a variable name.

You can use it if you want, but I really don't think “” is a good name for a variable.

How do you pronounce it?:)
 
Upvote 0

Forum statistics

Threads
1,224,613
Messages
6,179,903
Members
452,948
Latest member
Dupuhini

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