+ Reply to Thread
Results 1 to 10 of 10

VB Code to sort Names Alphabettically

  1. #1
    Valued Forum Contributor
    Join Date
    01-18-2007
    Location
    Georgia
    MS-Off Ver
    2010
    Posts
    4,434

    VB Code to sort Names Alphabettically

    Hello:

    Please refer to attached file.
    I am using below code to sort the names alphabetically.
    The beauty of the below code is that if I change the First Name then immediatly the names will be sorted.
    I need to add a piece of code so that
    1 : If the first name is "." then the data in that row needs to be deleted.
    2 : If any cell in Range ("B2:B33") is blank then clear the corresponding data in that row.

    Let me know if you have any questions.
    Thanks.

    Riz

    Please Login or Register  to view this content.
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,565

    Re: VB Code to sort Names Alphabettically

    Hi Riz,

    Not sure how your code was actually working considering there is no data in column A

    Anyway, this should do the job:

    Please Login or Register  to view this content.
    Regards,

    Robert
    ____________________________________________
    Please ensure you mark your thread as Solved once it is. Click here to see how
    If this post helps, please don't forget to say thanks by clicking the star icon in the bottom left-hand corner of my post

  3. #3
    Forum Contributor
    Join Date
    01-25-2013
    Location
    near Philly, PA USA
    MS-Off Ver
    Excel 2019
    Posts
    182

    Re: VB Code to sort Names Alphabettically

    This may do the job:
    Please Login or Register  to view this content.

  4. #4
    Valued Forum Contributor
    Join Date
    01-18-2007
    Location
    Georgia
    MS-Off Ver
    2010
    Posts
    4,434

    Re: VB Code to sort Names Alphabettically

    Hi Trebor:

    Very smart code, works great.
    One thing needs to added.
    If i add or change any name in First name column (Column B) then pop the message to let the sude know that you are adding another employee, do you want to delete the corresponding data in that row....
    The reason for this is that i want to overwrite the employee who is no more active so if I change the first name for new employee then want to make sure that the related information for inactive old employee clears out so that i can add new info.

    Please let me know if you have any questions.
    Thanks.

    Riz
    Last edited by rizmomin; 06-03-2015 at 08:01 PM.

  5. #5
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,565

    Re: VB Code to sort Names Alphabettically

    You can use this - the only slight downside is that it will always ask the question even if the name is edited but not changed (this would be quite rare in any case I would envisage):

    Please Login or Register  to view this content.
    Regards,

    Robert

  6. #6
    Valued Forum Contributor
    Join Date
    01-18-2007
    Location
    Georgia
    MS-Off Ver
    2010
    Posts
    4,434

    Re: VB Code to sort Names Alphabettically

    Hi Trebor:

    Seems to work fine.
    I will test more and let you know if any problem.
    Thanks

    Riz

  7. #7
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,565

    Re: VB Code to sort Names Alphabettically

    You're welcome.

    Thanks for marking the thread as solved and adding to my rep

  8. #8
    Valued Forum Contributor
    Join Date
    01-18-2007
    Location
    Georgia
    MS-Off Ver
    2010
    Posts
    4,434

    Re: VB Code to sort Names Alphabettically

    Hi Trebor:

    I am not sure what happened but it seems not to work.

    Please refer to attached file and your code.

    Let me know if you have any questions.
    Thanks.

    Riz
    Attached Files Attached Files

  9. #9
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,565

    Re: VB Code to sort Names Alphabettically

    Hi Riz,

    It's working for me

    One possible explanation could be if the macro fails midway during its execution for whatever reason, the EnableEvents option might be set to False hence stopping all macros from working. Assuming this is the problem, try the following where both screen updating and events are both set back to true if an error occurs:

    Please Login or Register  to view this content.
    The other thing to bear in mind is that the above code are event macros assigned only to Sheet1. They will therefore not execute on any other tab.

    Regards,

    Robert
    Last edited by Trebor76; 06-04-2015 at 08:46 PM.

  10. #10
    Valued Forum Contributor
    Join Date
    01-18-2007
    Location
    Georgia
    MS-Off Ver
    2010
    Posts
    4,434

    Re: VB Code to sort Names Alphabettically

    Hi Trebor:

    Seems to work now...
    Not sure if it was me who did something wrong.
    If there is any problem than i will let you know.

    Once again i appreciate all your help.

    Riz

+ 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. Replies: 1
    Last Post: 04-18-2014, 05:54 PM
  2. [SOLVED] How to sort the data by item code first, then sort them by date?
    By Zecond in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 08-04-2013, 01:55 AM
  3. Replies: 5
    Last Post: 01-13-2012, 03:20 PM
  4. Code to List all worksheet names (tab names)
    By howard101 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-17-2007, 12:51 PM
  5. [SOLVED] sort names
    By Tee in forum Excel General
    Replies: 4
    Last Post: 01-06-2006, 10:45 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