+ Reply to Thread
Results 1 to 9 of 9

Very urgent - Getting error Label not defined even after defining it.

  1. #1
    Registered User
    Join Date
    07-06-2018
    Location
    India
    MS-Off Ver
    7
    Posts
    18

    Very urgent - Getting error Label not defined even after defining it.

    Hi,

    When I tried to compile my VBA code I'm getting an error that says "Label not defined ". The label that it is referring to is getNextRowStudentVIIandVIII.
    I'm attaching the excel with the macro and vba code. Kindly help me. Its quite urgent. Thanks friends.
    Attached Files Attached Files

  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,468

    Re: Very urgent - Getting error Label not defined even after defining it.

    If this is a label as in
    Please Login or Register  to view this content.
    then the label needs a colon ( : ) on the end of it.


    Please Login or Register  to view this content.
    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
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Re: Very urgent - Getting error Label not defined even after defining it.


    Hi !

    As a good code does not need any label - except for error handling - since more than 20 years for VBA ! …

  4. #4
    Registered User
    Join Date
    07-06-2018
    Location
    India
    MS-Off Ver
    7
    Posts
    18

    Re: Very urgent - Getting error Label not defined even after defining it.

    Hi , I have given a colon. I rechecked. Still getting the same error

  5. #5
    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,468

    Re: Very urgent - Getting error Label not defined even after defining it.

    In this case, it is because you have put an "End Sub" after each of the Return statements. You will need to comment them out except for the last, the actual end of the subroutine. It will then compile. GoSub is not an approach that I use so I cannot comment on its effectiveness.

  6. #6
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Re: Very urgent - Getting error Label not defined even after defining it.


    Gosub and Goto are statements from more than 30 years ago of the VBA grand pa' : the BASIC !
    But they were left with the coming of some advanced version like Quick Basic and Turbo Basic more than 20 years ago.
    So since the beginning of VBA (more than 20 years) a good code does not need any Gosub neither any Goto statement …

  7. #7
    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,468

    Re: Very urgent - Getting error Label not defined even after defining it.

    @Marc L: I agree with you, but the OP is where the OP is, so it is perhaps more helpful to get the code to compile and, hopefully, work rather than criticising the approach. I'd probably use called subroutines or functions but, that said, I wouldn't know where to start to address this problem ... so the OP is one or two steps up on me.

  8. #8
    Registered User
    Join Date
    07-06-2018
    Location
    India
    MS-Off Ver
    7
    Posts
    18

    Re: Very urgent - Getting error Label not defined even after defining it.

    Thanks a lot friends. So many end subs !! I agree. It is compiling now. Thank you very much

  9. #9
    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,468

    Re: Very urgent - Getting error Label not defined even after defining it.

    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] error 400 - Label not defined help
    By Scoobster_doo in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-11-2017, 09:55 AM
  2. [Urgent/Simple] I have a defined function and a defined range of cells. How do I do =MyFun
    By excelfriend1 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 03-29-2016, 07:45 PM
  3. [SOLVED] Error message: Run-Time error '1004 '; application-defined or object-defined error
    By Davasu in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-23-2015, 06:52 AM
  4. error handler label not defined.
    By Rob K in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-17-2015, 09:27 AM
  5. VBA ERROR: run time error 1004: Application-defined or Object-defined error in excel 2013
    By AnanthKrishna in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-13-2015, 06:16 AM
  6. [SOLVED] Error " Run-time error '1004': application defined or object defined error
    By lengwer in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-11-2013, 07:26 AM
  7. Defining a Label
    By Richard in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-26-2006, 11:25 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