+ Reply to Thread
Results 1 to 4 of 4

Problem wih sort code on opening workbook

  1. #1
    Registered User
    Join Date
    03-13-2010
    Location
    Bedfordshire, England
    MS-Off Ver
    Excel 2010
    Posts
    60

    Problem wih sort code on opening workbook

    I have this code which works

    Please Login or Register  to view this content.
    When I add another worksheet to be sorted, as shown below it throws back a compile error, next without for. I'm very much a novice at vba and would really appreciate some pointers, have read various posts but can't work out why it does not work.

    Please Login or Register  to view this content.
    Last edited by BobTheRocker; 11-05-2010 at 05:16 AM.

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Problem wih sort code on opening workbook

    You have too many Next ws, you only need 1 after the protection lines

    Please Login or Register  to view this content.
    The rest of your code needs tidying, you don't actually need to select sheets & ranges
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

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

    Re: Problem wih sort code on opening workbook

    If you indent you code you will see the extra "next ws" line more clearly out of sync.

    Please Login or Register  to view this content.
    You can reduce the repeated code
    Please Login or Register  to view this content.
    Cheers
    Andy
    www.andypope.info

  4. #4
    Registered User
    Join Date
    03-13-2010
    Location
    Bedfordshire, England
    MS-Off Ver
    Excel 2010
    Posts
    60

    Re: Problem wih sort code on opening workbook

    Thanks guys, very helpful, Andy that was brilliant, everyday I learn so much from these forums. I did have to modify your code slightly to get it to work the last next had to have the ws removed.

    Please Login or Register  to view this content.
    I really need to start some serious study on compiling vba. Thank you

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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