+ Reply to Thread
Results 1 to 3 of 3

variable not defined error

  1. #1
    Forum Contributor
    Join Date
    12-12-2012
    Location
    Los Angeles
    MS-Off Ver
    Excel 2010
    Posts
    448

    variable not defined error

    Hello. I'm just doing some practicing with beginner macros. I input this code into the macro and it says variable not defined error. What is the issue? Thanks.

    Please Login or Register  to view this content.
    Last edited by Leith Ross; 05-16-2013 at 07:50 PM. Reason: Added Code Tags

  2. #2
    Forum Expert
    Join Date
    12-15-2009
    Location
    Chicago, IL
    MS-Off Ver
    Microsoft Office 365
    Posts
    3,177

    Re: variable not defined error

    Please Login or Register  to view this content.

  3. #3
    Valued Forum Contributor
    Join Date
    03-21-2013
    Location
    cyberia
    MS-Off Ver
    Excel 2007
    Posts
    457

    Re: variable not defined error

    Probably it's because you have "Option Explicit" at the top of the module page.

    To get around it you can either disable or delete the "Option Explicit", or, better, explicitly declare the variable on the lines of
    Dim Num as Single, or Dim Num as Double or just Dim Num (the first is best in your context)

    I wouldn't recommend using Dim Num as Long unless you want to confine yourself to whole numbers.

    To see why not, try Dim Num as Long and then enter 8.5 in your inputbox. Do you get the cube root of 8.5?

+ 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