+ Reply to Thread
Results 1 to 12 of 12

VBA Variable Range Sort

  1. #1
    Registered User
    Join Date
    11-24-2011
    Location
    Germany
    MS-Off Ver
    Excel 2007
    Posts
    28

    Question VBA Variable Range Sort

    Hello, I am trying to setup a macro to sort a variable range. I need to sort from a static range G14:O14 to down. In the example, I have selected range G14:O100, but i could have more rows, 105, 110 etc., so i would need to make it variable. Here is what i have:

    Please Login or Register  to view this content.
    Last edited by arlu1201; 04-10-2013 at 09:47 AM.

  2. #2
    Forum Expert
    Join Date
    11-28-2012
    Location
    Guatemala
    MS-Off Ver
    Excel 2010
    Posts
    2,394

    Re: VBA Variable Range Sort

    Please Login or Register  to view this content.

  3. #3
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: VBA Variable Range Sort

    Slight modification to rcm's code above (excluding the Select statements)

    Please Login or Register  to view this content.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  4. #4
    Forum Expert
    Join Date
    11-28-2012
    Location
    Guatemala
    MS-Off Ver
    Excel 2010
    Posts
    2,394

    Re: VBA Variable Range Sort

    Yes arlu1201 is right!

  5. #5
    Registered User
    Join Date
    11-24-2011
    Location
    Germany
    MS-Off Ver
    Excel 2007
    Posts
    28

    Re: VBA Variable Range Sort

    Thanks arlu :-) Tried it too, it shows a problem at ".Apply"...

  6. #6
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: VBA Variable Range Sort

    What is the error you get?

  7. #7
    Registered User
    Join Date
    11-24-2011
    Location
    Germany
    MS-Off Ver
    Excel 2007
    Posts
    28

    Re: VBA Variable Range Sort

    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.

  8. #8
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: VBA Variable Range Sort

    You have no headers in your data right? Is the starting data set from G14:O14 having any blank cells?

  9. #9
    Registered User
    Join Date
    11-24-2011
    Location
    Germany
    MS-Off Ver
    Excel 2007
    Posts
    28

    Re: VBA Variable Range Sort

    Well, yes, the range G14:O14 is already the data itself. I have headers in the range G12:O12, G13:O13 is an empty range (for the optic only). My current data ends at G79:O79 and then i have entered still some formulas till G100:O100, that it will get the new data set during the next update. Makes sense?
    Thanks

  10. #10
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: VBA Variable Range Sort

    Can you upload a sample of your data to make it more clear?

  11. #11
    Registered User
    Join Date
    11-24-2011
    Location
    Germany
    MS-Off Ver
    Excel 2007
    Posts
    28

    Re: VBA Variable Range Sort

    Hi Arlu1201, sorry, it took some time to answer, too much stress last days.... See my "fast made" example attached. Thanks!
    Attached Files Attached Files

  12. #12
    Registered User
    Join Date
    11-24-2011
    Location
    Germany
    MS-Off Ver
    Excel 2007
    Posts
    28

    Re: VBA Variable Range Sort

    ... forgot to mention, that my team names are vary from week to week, so i would need to have this range as variable... Thanks!

+ 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