+ Reply to Thread
Results 1 to 8 of 8

macro to generate sorted table from unsorted list?

  1. #1
    Registered User
    Join Date
    03-24-2008
    Posts
    14

    macro to generate sorted table from unsorted list?

    on worksheet 1, I have 100 unsorted rows with:

    First Name | Last Name | Phone Number

    I would like to have this formatted on worksheet 2 with a specified (via a variable) number of rows and columns in alphabetical order by FirstName LastName | Phone Number.

    So the output would be something like:

    NAME | PHONE | NAME | PHONE | NAME | PHONE --> through column break
    Abe Smith | 12345
    Adam Johnson | 12346
    ...
    ...
    ...
    through row break.


    So in above example, columns would be 6 (NAME|PHONE|NAME|PHONE|NAME|PHONE) and rows might be 36.

    The First 2 columns might have data for names starting with A-F, the next might have data for G-J, depending of course on the names in the original unsorted list of worksheet 1.


    Can someone help me with this?
    Last edited by VBA Noob; 10-17-2008 at 12:58 PM.

  2. #2
    Registered User
    Join Date
    03-24-2008
    Posts
    14
    Any ideas here?

  3. #3
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678
    It would be easier to help if you posted a workbook with a useful amount of data and the start of expected results.

    BTW, why not just sort the data on the first worksheet?
    Entia non sunt multiplicanda sine necessitate

  4. #4
    Registered User
    Join Date
    03-24-2008
    Posts
    14
    I have attached an example worksheet...


    Could someone take a look?
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    03-24-2008
    Posts
    14

    Re: macro to generate sorted table from unsorted list?

    Does anyone have an idea how I can do this?

  6. #6
    Forum Contributor
    Join Date
    02-23-2006
    Location
    Near London, England
    MS-Off Ver
    Office 2003
    Posts
    770

    Re: macro to generate sorted table from unsorted list?

    Why are you wanting to constrain both the number of rows, and the number of columns in your generated table?
    It would be normal to say it can be 6 columns, and however many rows it needs, or to say it can be 36 rows, and how ever many columns it needs, but by wanting to specify both you could cause your self problems.
    For instance imagine you have 100 records, and you specify that your table can be 6 columns by 5 rows.... that will only allow space for 15 entries, what happens to the ones you didn't allow to fit?

    Incidently, as above, why don't you just sort the original list?

  7. #7
    Forum Contributor
    Join Date
    02-23-2006
    Location
    Near London, England
    MS-Off Ver
    Office 2003
    Posts
    770

    Re: macro to generate sorted table from unsorted list?

    I'm looking at this for you at the moment, but the data in your example spreadsheet is not formatted the same as you suggested in your original post. I shall code based on the example spreadsheet and then you can change it if neccasary

  8. #8
    Forum Contributor
    Join Date
    02-23-2006
    Location
    Near London, England
    MS-Off Ver
    Office 2003
    Posts
    770

    Post Re: macro to generate sorted table from unsorted list?

    See if the attached satifies your needs.
    It only allows you to specify the number of columns as it makes little sense to specify rows as well.
    The output is generated on the "Output" worksheet.
    Run the macro by running "Generate_It"

+ 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. A macro to cut data from one table and paste it onto another worksheet
    By dandavis1 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-22-2008, 07:45 AM
  2. Macro for copy/insert into expanding table
    By Soslowgt in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 02-06-2008, 07:24 PM
  3. Pivot Table List refreshing problem
    By TK5 in forum Excel General
    Replies: 6
    Last Post: 11-07-2007, 10:50 AM
  4. Use Macro to add data to end of a list
    By graham1607 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 09-23-2007, 01:38 PM
  5. Need a macro to search and remake any list
    By mfrancis in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-21-2006, 04:54 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