+ Reply to Thread
Results 1 to 3 of 3

Need help fixing macros due to Run-Time error 1004 Sort Reference is Not Valid

  1. #1
    Registered User
    Join Date
    05-11-2013
    Location
    Portland
    MS-Off Ver
    Excel 2007
    Posts
    9

    Need help fixing macros due to Run-Time error 1004 Sort Reference is Not Valid

    Hello,

    I am trying to write a macros to select a range of cells and then sort alphabetically in ascending order using information found in another range. For my example below the larger range is called "Team Ambrosio" and within that range is another range called "CSR_Ambrosio". I am trying to write a macros that will sort the larger range (Team_Ambrosio) in ascending order based on the text values of the smaller range (SCR_Ambrosio).

    I tried recording a macros and then substituting the cell ranges with the names of the cell ranges. I then replaced the Worksheet name using "ActiveSheet" because I need the macros to run on whatever sheet is active at the time. This may be where my problem is, I'm not sure. But I do not want to use the "Worksheet Name" because the name will be changing every time I create a new worksheet.

    I receive the following error: Run-time error '1004': The sort reference is not valid. Make sure that it's within the data you want to sort, and the first Sort By box isn't the same or blank. The debugger takes me to the ".Apply" line below. Any help would be appreciated on how to get this to function correctly. Thanks!

    Please Login or Register  to view this content.
    Last edited by Leith Ross; 06-15-2013 at 08:19 PM. Reason: Added Code Tags

  2. #2
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Need help fixing macros due to Run-Time error 1004 Sort Reference is Not Valid

    is CSR_Ambrosio an entire column of the Team_Ambrosio range?
    Josie

    if at first you don't succeed try doing it the way your wife told you to

  3. #3
    Registered User
    Join Date
    05-11-2013
    Location
    Portland
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: Need help fixing macros due to Run-Time error 1004 Sort Reference is Not Valid

    I figured it out on my own. I changed "CSR_Ambrosio" to the column ("B:B") instead and it works great. CSR_Ambrosio was one row shy of the full length of Team_Ambrosio which was causing the problem.

+ 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