+ Reply to Thread
Results 1 to 9 of 9

Getting compile error variable not define

  1. #1
    Forum Contributor
    Join Date
    06-29-2014
    Location
    India
    MS-Off Ver
    2010 Windows 10 64 bits
    Posts
    1,269

    Getting compile error variable not define

    Hi friends,

    I’m getting compile error ‘variable not define’ in the following code.
    If the surname is found then I want a first congratulation message.
    If the surname is not found then I want a second ‘sorry’ message.

    If I delete ‘option explicit’ then the code works fine but if the surname is found then it gives a ‘sorry’ message instead of ‘congratulation’ message.

    Please Login or Register  to view this content.
    Any help will be highly appreciated.

    Thanking you in anticipation.
    Sincerely,

    mso3

  2. #2
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Getting compile error variable not define

    "found" is a variable which has neither been declared nor defined. In addition, you are using it as a parameter for an if statement which given the lack of definition will always be false; hence the second message box. Give more specifics including an example workbook for new code.

  3. #3
    Forum Contributor
    Join Date
    06-29-2014
    Location
    India
    MS-Off Ver
    2010 Windows 10 64 bits
    Posts
    1,269

    Re: Getting compile error variable not define

    I'm getting error on 'autofilter' variable not define.

    Please see the attached workbook.

    Thanking you,
    Attached Files Attached Files

  4. #4
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: Getting compile error variable not define

    maybe so (if we use the the proposed approach)
    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    06-29-2014
    Location
    India
    MS-Off Ver
    2010 Windows 10 64 bits
    Posts
    1,269

    Re: Getting compile error variable not define

    Hi Nilem,
    Perfect! It's working fine.

    Please explain me the following line because I didn't understand it.

    If .Columns(1).SpecialCells(2).SpecialCells(12).Count > 1 Then

    Thank you for your cooperation and solution.

  6. #6
    Forum Contributor
    Join Date
    06-29-2014
    Location
    India
    MS-Off Ver
    2010 Windows 10 64 bits
    Posts
    1,269

    Re: Getting compile error variable not define

    Hello Nilem,
    My database contains 5000 rows. After inserting and running the macro I have a compile error 6 over flow on the following line.

    Please Login or Register  to view this content.
    Solution please!

    Thanking you,

  7. #7
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Getting compile error variable not define

    Change the .Columns(1) to .Columns(5). See if that solves your problem.

  8. #8
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: Getting compile error variable not define

    Hi mso3,
    I think this option is better
    Please Login or Register  to view this content.

  9. #9
    Forum Contributor
    Join Date
    06-29-2014
    Location
    India
    MS-Off Ver
    2010 Windows 10 64 bits
    Posts
    1,269

    Re: Getting compile error variable not define

    Hi stnkynts and Nilem,

    Thank you to both of you. Both the solutions are working fine.

    Thank you for solving the problem.

+ 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] Getting compile error variable not define
    By mso3 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-08-2015, 10:43 PM
  2. [SOLVED] Getting compile error 'sub or function not define'
    By mso3 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-12-2015, 09:31 AM
  3. [SOLVED] Getting compile error sub or function not define
    By mso3 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 12-14-2014, 11:32 PM
  4. [SOLVED] Compile Error 'Sub or Function is not define' error on Private Sub Getdata()
    By HafizuddinLowhim in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-24-2014, 11:17 AM
  5. Getting compile error sub or function not define
    By mso3 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-01-2014, 11:01 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