+ Reply to Thread
Results 1 to 6 of 6

Loop to Sort Columns

  1. #1
    Registered User
    Join Date
    04-09-2012
    Location
    Blackpool, England
    MS-Off Ver
    Excel 2007
    Posts
    9

    Loop to Sort Columns

    Having a problem trying to do a simple loop to sort a number of individual columns A:K (though this is not a set number and I have a variable that stores the number of columns used) (Row 1 has headers).
    The data in each column is independent of the others.

    I have recorded a macro to see the structure of a simple sort but I am coming unstuck in two area 1stly getting the number of rows to sort on each loop and 2ndly with using R1C1 within the search code


    Please Login or Register  to view this content.
    I thought wrongly something like

    Please Login or Register  to view this content.
    But it doesn't like the syntax, and the row length is only 1. Any help much appreciated.
    Last edited by hornbyOO; 10-22-2012 at 06:16 AM.

  2. #2
    Valued Forum Contributor Charles's Avatar
    Join Date
    02-10-2004
    Location
    Biloxi
    MS-Off Ver
    Windows 7, Excel 2003,2007 & Mac2011
    Posts
    845

    Re: Loop to Sort Columns

    hi,

    You have a ":" where you should have ",".

    Please Login or Register  to view this content.
    Charles

    There are other ways to do this, this is but 1 !
    Be Sure you thank those who helped.
    IF YOU'RE SATISFIED BY ANY MEMBERS RESPONSE TO YOUR ISSUE PLEASE USE THE STAR ICON AT THE BOTTOM LEFT OF THE POST UNDER THEIR NAME.

  3. #3
    Registered User
    Join Date
    04-09-2012
    Location
    Blackpool, England
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: Loop to Sort Columns

    Thanks for quick reply, I'm sure you're probably right but I can't check st the moment.
    You wouldn't know how I can check a how many rows in each column as I loop through would you ?

    Thanks again

  4. #4
    Valued Forum Contributor Charles's Avatar
    Join Date
    02-10-2004
    Location
    Biloxi
    MS-Off Ver
    Windows 7, Excel 2003,2007 & Mac2011
    Posts
    845

    Re: Loop to Sort Columns

    hi,

    Try this bit of code.
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    04-09-2012
    Location
    Blackpool, England
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: Loop to Sort Columns

    Quote Originally Posted by Charles View Post
    hi,

    You have a ":" where you should have ",".

    Please Login or Register  to view this content.
    Steps through to " .SetRange = Range(Cells(1, i), Cells(iRowLen, i))" and then fails with 'Runtime Error 438 Object doesn't support this property or method'


    Thanks
    Last edited by hornbyOO; 10-22-2012 at 04:29 AM. Reason: Fixed iRowLen problem/add runtime error number

  6. #6
    Registered User
    Join Date
    04-09-2012
    Location
    Blackpool, England
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: Loop to Sort Columns

    Didn't manage to sort the R1C1 problem in the sort routine, but took another path by highlighting the column data and using the following

    Please Login or Register  to view this content.

+ 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