+ Reply to Thread
Results 1 to 8 of 8

Help w VBA Sorting Named Ranges

  1. #1
    Registered User
    Join Date
    09-23-2014
    Location
    Wisconsin
    MS-Off Ver
    2013
    Posts
    28

    Help w VBA Sorting Named Ranges

    I have three ranges of data where I want each of the sets sorted ascending by the 5th column (1st & 2nd sets) and the 2nd column (3rd set)

    First range of data is named "Week1IndividualStandings"
    Second range is named "Week1OverallStandings:
    Third range is named "Week1TeamStandings"

    I have the following code, but I'm getting the error: Run-time error '1004': Sort method of Range class failed.

    Please Login or Register  to view this content.
    I'm very new to VBA and don't know where to start to fix this.
    Last edited by JBeaucaire; 10-21-2014 at 12:22 AM. Reason: Added missing CODE tags. Please read and follow the Forum Rules, link above in the menu bar. Thanks.

  2. #2
    Valued Forum Contributor
    Join Date
    10-15-2007
    Location
    Home
    MS-Off Ver
    Office 2010, W10
    Posts
    373

    Re: Help w VBA Sorting Named Ranges

    Hi

    This would happen if the worksheet is protected. Is that the case?

  3. #3
    Registered User
    Join Date
    09-23-2014
    Location
    Wisconsin
    MS-Off Ver
    2013
    Posts
    28

    Re: Help w VBA Sorting Named Ranges

    I do have that particular worksheet protected. Thank you for that info! I didn't know you couldn't run a macro on a protected sheet. Is there a workaround to that?

  4. #4
    Valued Forum Contributor
    Join Date
    10-15-2007
    Location
    Home
    MS-Off Ver
    Office 2010, W10
    Posts
    373

    Re: Help w VBA Sorting Named Ranges

    Quote Originally Posted by jlheath01 View Post
    I do have that particular worksheet protected. Thank you for that info! I didn't know you couldn't run a macro on a protected sheet. Is there a workaround to that?
    Well, you can

    Unprotect
    Sort
    Protect

  5. #5
    Registered User
    Join Date
    09-23-2014
    Location
    Wisconsin
    MS-Off Ver
    2013
    Posts
    28

    Re: Help w VBA Sorting Named Ranges

    That sort of defeats the purpose of a protected worksheet

  6. #6
    Valued Forum Contributor
    Join Date
    10-15-2007
    Location
    Home
    MS-Off Ver
    Office 2010, W10
    Posts
    373

    Re: Help w VBA Sorting Named Ranges

    Quote Originally Posted by jlheath01 View Post
    That sort of defeats the purpose of a protected worksheet
    Well, you cannot say at the same time
    - I want the worksheet to remain unchanged
    - I want to change the worksheet



    If you want the worksheet to remain unchanged then you cannot sort. If you want to sort then unprotect, change and protect.

    Notice that it does not defeat the purpose completely.
    - The worksheet is protected and so the user will not change something by accident
    - When you sort you (the author, not the user)are using vba and so we can say that you are doing it staying in control. The user can have for ex. a button to invoke the sort, but won't have access to the worksheet when it is unprotected

    You just have to figure out what's the best course of action in your specific case.

  7. #7
    Registered User
    Join Date
    09-23-2014
    Location
    Wisconsin
    MS-Off Ver
    2013
    Posts
    28

    Re: Help w VBA Sorting Named Ranges

    I see what you're saying. In my mind, I was thinking the cells where the data & formulas are located could be protected, but a user could still sort. Thank you for all of your help.

  8. #8
    Valued Forum Contributor
    Join Date
    10-15-2007
    Location
    Home
    MS-Off Ver
    Office 2010, W10
    Posts
    373

    Re: Help w VBA Sorting Named Ranges

    I'm glad it helped. Thanks for the feedback.

+ 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] Sorting Named Ranges
    By Seve in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-20-2013, 10:19 AM
  2. Cycle Through Sheets & Sorting Named Ranges
    By jordan2322 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-12-2012, 09:53 PM
  3. Sorting Data with Named Ranges
    By kzmr1234 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-23-2010, 12:52 PM
  4. sorting rows containing named ranges
    By Exceler in forum Excel General
    Replies: 1
    Last Post: 09-11-2008, 09:14 PM
  5. Sorting data with Named Ranges
    By Gap in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-22-2006, 12:20 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