+ Reply to Thread
Results 1 to 7 of 7

select case compile error

  1. #1
    Registered User
    Join Date
    11-05-2007
    Posts
    54

    select case compile error

    hey all,


    i've got the following code that used to work until I changed something and now I can't work out why it doesn't work.

    Please Login or Register  to view this content.


    Can anyone work out why I am getting the
    "Case Without Select Case" Error

    Thanks in advance.
    Last edited by karl1985; 12-02-2010 at 05:09 AM.

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,485

    Re: select case compile error

    If you indent your code you will see that the actual problem is a missing End If rather than Case, even if that is what the compiler reported.

    Please Login or Register  to view this content.
    Also some of the code does not make sense as it will never be executed due to a proceeding Exit Sub.
    Cheers
    Andy
    www.andypope.info

  3. #3
    Registered User
    Join Date
    11-05-2007
    Posts
    54

    Re: select case compile error

    Thanks for your help, before I saw your answer I actually did what you said. I started a new document and moved each part of the code over to the new sheet constantly checking for errors and in the meatime cleaning up my code with the use of indenting.

    I ended up witht eh following which works a treat


    Please Login or Register  to view this content.



    I'm sure the code could still be made more efficient, but i've changed the ranges to named ranges and indented the code so that its much easier to read and follow.

    I did try having subroutines for each case with the "call macro" function but that didn'tseem to work so I am left with the above.


    Thank you for all your help, yet another positive response from a great bunch of people.

    Karl

  4. #4
    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
    49,020

    Re: select case compile error

    You're welcome. Thanks for the feedback.

    Whats with ...

    Please Login or Register  to view this content.

    Where are you trying to get to?

    And do you need to select cells at all?


    Regards
    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


  5. #5
    Registered User
    Join Date
    11-05-2007
    Posts
    54

    Re: select case compile error

    i'm trying to get to column B of the active row of which the value of that cell needs to = vNOMISdis


    something like:

    vNOMISdis = DISCELL.Offset("current row, column B) .value


    I just don't know how to put that piece of code together and got lazy, found a solution and left it.
    Last edited by karl1985; 12-02-2010 at 05:16 AM.

  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
    49,020

    Re: select case compile error

    Try changing:

    Please Login or Register  to view this content.

    To:

    Please Login or Register  to view this content.

    And remove all the positioning statements.


    Regards

  7. #7
    Registered User
    Join Date
    11-05-2007
    Posts
    54

    Re: select case compile error

    Billiant, proberbly the simpliest part of my code.

    a great tidy up for my code.

    Thanks again

    Very Happy.

+ 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