+ Reply to Thread
Results 1 to 7 of 7

My some basic programms always show syntax error when i run macros

Hybrid View

  1. #1
    Registered User
    Join Date
    02-26-2013
    Location
    pakistan
    MS-Off Ver
    Excel 2007
    Posts
    22

    My some basic programms always show syntax error when i run macros

    Sub CubeRoot()
    Num = InputBox(“Enter a positive number”)
    MsgBox Num ^ (1/3) & “ is the cube root.”
    End Sub
    why this macro always gives my syntax error ?
    Last edited by syedfahadjalali; 03-02-2013 at 04:44 PM.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,304

    Re: My some basic programms always show syntax error when i run macros

    This works for me. I've changed the quotes ... did you copy this code from somewhere?

    Sub CubeRoot()
    Dim Num
    Num = InputBox("Enter a positive number")
    MsgBox Num ^ (1 / 3) & " is the cube root."
    End Sub

    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    02-26-2013
    Location
    pakistan
    MS-Off Ver
    Excel 2007
    Posts
    22

    Re: My some basic programms always show syntax error when i run macros

    if i copy any basic code from my tutorial pdf file it always give me systax error

  4. #4
    Registered User
    Join Date
    02-26-2013
    Location
    pakistan
    MS-Off Ver
    Excel 2007
    Posts
    22

    Re: My some basic programms always show syntax error when i run macros

    Thanks after retyping the quotes it is working fine for me :D

  5. #5
    Registered User
    Join Date
    02-26-2013
    Location
    pakistan
    MS-Off Ver
    Excel 2007
    Posts
    22

    Re: My some basic programms always show syntax error when i run macros

    yes i copied this code from a pdf tutorial

  6. #6
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,304

    Re: My some basic programms always show syntax error when i run macros

    They're using a different double quote character ... so you will need to do a global replacement of what you get from your PDF file for this double quote (").


    Regards, TMS

  7. #7
    Forum Expert
    Join Date
    10-10-2008
    Location
    Northeast Pennsylvania, USA
    MS-Off Ver
    Excel 2007
    Posts
    2,387

    Re: My some basic programms always show syntax error when i run macros

    syedfahadjalali,

    The following works for me:

    
    Option Explicit
    Sub CubeRootV2()
    ' stanleydgromjr, 03/02/2013
    ' http://www.excelforum.com/excel-programming-vba-macros/903853-my-some-basic-programms-always-show-syntax-error-when-i-run-macros.html
    Dim Num
    Num = InputBox("Enter a positive number")
    MsgBox (Num ^ 1 / 3 & " is the cude root of " & Num)
    End Sub
    Have a great day,
    Stan

    Windows 10, Excel 2007, on a PC.

    If you are satisfied with the solution(s) provided, please mark your thread as Solved by clicking EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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