+ Reply to Thread
Results 1 to 4 of 4

novice's clueless about why VBA shows an error message

  1. #1
    Forum Contributor
    Join Date
    02-28-2013
    Location
    NY, USA
    MS-Off Ver
    Excel 2019
    Posts
    101

    novice's clueless about why VBA shows an error message

    An absolute newbie to Excel VBA. so I copied a script from "VBA for dummies" and pasted it in a new module from a new worksheet in a new workbook. Below is what I pasted.

    Sub GuessName()
    Msg = “Is your name “ & Application.UserName & “?”
    Ans = MsgBox(Msg, vbYesNo)
    If Ans = vbNo Then MsgBox “Oh, never mind.”
    If Ans = vbYes Then MsgBox “I must be
    psychic!”
    End Sub

    When I hit "Run", it showed "Compile error: Syntax error". A yellow arrow showed up next to "Sub GuessName ()", which is highlighted in yellow. And it seems that the second line "Msg = "..... " is also highlighted, but in blue.
    I have NO idea why there is a Syntax error. The book didn't say anything (so I assume there should be NO Syntax error". Any help ??

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: novice's clueless about why VBA shows an error message

    VBA uses straight quotes, not left and right quotes as in your post.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Forum Contributor
    Join Date
    02-28-2013
    Location
    NY, USA
    MS-Off Ver
    Excel 2019
    Posts
    101

    Re: novice's clueless about why VBA shows an error message

    OMG !!!! THANK YOU !! - didn't notice this change - not sure why a simple copy-paste would change the quotation marks from straight to slanted

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: novice's clueless about why VBA shows an error message

    You're welcome.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Help with error handling for novice VBA user
    By malky1976 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-10-2015, 05:18 AM
  2. [SOLVED] Excel Novice - attempting to use SUMPRODUCT/SUMIF/INDIRECT but cell shows #REF
    By mbasi in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 03-17-2013, 05:44 AM
  3. An error message on open - a totally blank VBA message box
    By Mr_Tigas in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-05-2013, 11:29 AM
  4. Attempt to automate goal seek; keep getting Type 13 mismatch error; VBA novice
    By exceljs88 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-14-2012, 11:51 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1