+ Reply to Thread
Results 1 to 9 of 9

Macro for alphabetizing... more difficult that it sounds

  1. #1
    Registered User
    Join Date
    11-06-2008
    Location
    Illinois
    Posts
    63

    Macro for alphabetizing... more difficult that it sounds

    I am trying to automate a process that I do every day in which I manually re-arrange 2 columns of names alphabetically so they can easily be viewed side-by-side. This name list is dynamic and is always changing and all recurring names would be exactly the same every time.

    Needless to say doing this everyday is boring and wastes a lot of time (roughly 5 minutes every day.... multiply that by 248 work days/year and you get 20.67 hours/year!!).

    Please see the file I attached and you would know what I mean.

    Best,

    Nick
    Attached Files Attached Files
    Last edited by Nickster64; 12-15-2008 at 03:10 PM.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello Nickster64,

    Do you ever have duplicate names in the same column? How many days will need to be sorted at time?

    Sincerely,
    Leith Ross

  3. #3
    Forum Contributor
    Join Date
    02-27-2008
    Posts
    764

    macro

    Hi
    try this macro. Don't add grand total. the macro will do it for you.
    Ravi
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    11-06-2008
    Location
    Illinois
    Posts
    63

    Arrow

    Do you ever have duplicate names in the same column? How many days will need to be sorted at time?
    Leith,

    No, there will never be duplicate names in the same column. At max only 2 days will need to be sorted at a time -- previous day, and current day.


    try this macro. Don't add grand total. the macro will do it for you.
    ravishankar,

    Your macro worked great! I have a few questions though...
    (1) Why was Williams, Ace was left out after I ran the macro? (in the 12/11/08 column)

    (2) Would this macro work with any number and combination of names in either list?

    (3) My data comes from a pivot table where the "Grand Total" is automatically generated and included in the names list. Could your macro treat 'Grand Total' as another name value which needs to be arranged side-by-side? (I tried to 'comment out your Grand Total code within your macro but when I ran it Grand Total was just deleted all together)

    (4) Finally, I am self-teaching myself Excel VB code and have learned much from this site and people's explanations. Could you provide me an explanation with why you chose the codes that you used for this macro so I may learn?

    Best,

    Nick

  5. #5
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello Nick,

    The attached workbook contains 2 modules. Each module holds 1 macro. The macros are FindLastRow and ReformatData. This macro will work with the day columns being of unequal length. The grand total lines are added as the last line of the reformatted data. You can change the names of the worksheets and the starting row of data in the macro to match your actual setup. These variables are marked in red. A button has been added to the "Before" worksheet to run the macro.

    Find Last Row Macro
    Please Login or Register  to view this content.
    Reformat Data Macro
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    11-06-2008
    Location
    Illinois
    Posts
    63
    Leith,

    Your macro works excellent, thanks! I am going to break this down to understand it and learn from it.

    Nick

  7. #7
    Registered User
    Join Date
    11-06-2008
    Location
    Illinois
    Posts
    63

    Question

    Quote Originally Posted by Leith Ross View Post
    You can change the names of the worksheets and the starting row of data in the macro to match your actual setup. These variables are marked in red.
    Leith, in the actual workbook I use just 1 worksheet and do not have a BEFORE or AFTER sheets. This worksheet's name is the current date "dd-mm-yy". I figured I could replace your red variables with 'Active.Sheet' code but it's not working.

    What would you recommend?

    Thanks,

    Nick

  8. #8
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678
    This runs on the active sheet:
    Please Login or Register  to view this content.
    Entia non sunt multiplicanda sine necessitate

  9. #9
    Registered User
    Join Date
    11-06-2008
    Location
    Illinois
    Posts
    63
    Perfect. Thank you all,

    Nick

+ 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