Results 1 to 2 of 2
  1. #1
    New Lounger
    Join Date
    Sep 2013
    Posts
    11
    Thanks
    4
    Thanked 0 Times in 0 Posts

    how to sort this type of table using vba

    Hello everybody



    i have a table with
    1 230 450 1 301
    2 230 450 2 340
    7 230 450 7 350
    65 230 450 301 501
    67 230 450 340 502
    71 230 450 350 546
    129 230 450 501 701
    131 230 450 502 702
    135 230 450 546 747




    i want to sort in order that


    select 1st column having number "1"
    row containing "1" number 5th column text is "301"
    2nd row should be 4th column with "301"
    it has 5th column "501"
    3rd row should be 4th column with 501 and so on untill there no number matching 5th and 4th column


    Then select "2" in the 1st column and do the same


    this process goes on end of the 1st column


    the above example should have
    1 230 450 1 301
    65 230 450 301 501
    129 230 450 501 701
    2 230 450 2 340
    67 230 450 340 502
    131 230 450 502 702
    7 230 450 7 350
    71 230 450 350 546
    135 230 450 546 747


    please guide me

    thanks

    gvg

  2. #2
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,852
    Thanks
    4
    Thanked 259 Times in 239 Posts
    Again we are getting the chance to do your homework for you. How about you make some kind of attempt first and then we can assist you to refine your code.

    The basic process I would use is:
    Use sort to rearrange the rows and put the first row in place
    Add an index column to the end of that row of data so you can sort on this
    Start a Loop
    - Use Split to extract the final number from current row
    - Use search to find the cell that begins with the extracted number
    - if found, add the next index number to the index column
    Loop
    When all rows are tagged, sort on the index column
    Andrew Lockton, Chrysalis Design, Melbourne Australia

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •