+ Reply to Thread
Results 1 to 9 of 9

how to sort column in listbox vba based on a column of 8 in the list box?

  1. #1
    Registered User
    Join Date
    10-16-2021
    Location
    egypt
    MS-Off Ver
    2016
    Posts
    75

    Red face how to sort column in listbox vba based on a column of 8 in the list box?

    need help pls
    How can the list box be rearranged based on sort a column of 8 in the list box, knowing that the list box is made up of 20 columns?
    thank s for your interesting

  2. #2
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: how to sort column in listbox vba based on a column of 8 in the list box?

    I would write the contents of your listbox to Excel

    Then Sort the Data in Excel

    Finally Copy the Data back to the Listbox

    Please Login or Register  to view this content.
    Last edited by mehmetcik; 10-24-2021 at 05:10 PM.
    My General Rules if you want my help. Not aimed at any person in particular:

    1. Please Make Requests not demands, none of us get paid here.

    2. Check back on your post regularly. I will not return to a post after 4 days.
    If it is not important to you then it definitely is not important to me.

  3. #3
    Registered User
    Join Date
    10-16-2021
    Location
    egypt
    MS-Off Ver
    2016
    Posts
    75

    Re: how to sort column in listbox vba based on a column of 8 in the list box?

    thanks for that but i have a long code used it in list box with some conditions thus i need to sort the column no 8 in the listbox

  4. #4
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: how to sort column in listbox vba based on a column of 8 in the list box?

    Hi, I found this code snippet a long time ago and use it now works for me:

    Please Login or Register  to view this content.
    Place is in a normal VBA Module (not in the Userform's project)
    In the userform you call the routine AFTER the listbox has been filled and the syntax is:

    Please Login or Register  to view this content.
    7 is the column number, if your Listbox has 20 columns the count starts a 0, the Listbox1 is the name of your Listbox, this will sort the listbox on the selected column ascending, if you want it descending order

    Please Login or Register  to view this content.
    Happy coding
    ---
    Hans
    "IT" Always crosses your path!
    May the (vba) code be with you... if it isn't; start debugging!
    If you like my answer, Click the * below to say thank-you

  5. #5
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: how to sort column in listbox vba based on a column of 8 in the list box?

    Hi, you still asleep in Egypt?
    Have you tried the code?

  6. #6
    Registered User
    Join Date
    10-16-2021
    Location
    egypt
    MS-Off Ver
    2016
    Posts
    75

    Re: how to sort column in listbox vba based on a column of 8 in the list box?

    thank you very much

  7. #7
    Registered User
    Join Date
    10-16-2021
    Location
    egypt
    MS-Off Ver
    2016
    Posts
    75

    Re: how to sort column in listbox vba based on a column of 8 in the list box?

    i was away

  8. #8
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: how to sort column in listbox vba based on a column of 8 in the list box?

    Okay, no problem, I was just curious to hear it it worked.
    The advantage is that you can use for any list box and don't have to program it separately

  9. #9
    Registered User
    Join Date
    10-16-2021
    Location
    egypt
    MS-Off Ver
    2016
    Posts
    75

    Re: how to sort column in listbox vba based on a column of 8 in the list box?

    yes, thank you

+ 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: 8
    Last Post: 05-12-2019, 07:35 AM
  2. [SOLVED] Alpha Sort Table Column based on Criteria for Validation List
    By HeyInKy in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 04-18-2017, 04:13 PM
  3. Sort by second column listbox
    By hitmen in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-20-2014, 07:24 AM
  4. Multicolumn Listbox - How to remove duplicates and sort by first column?
    By s2jrchoi in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-17-2013, 02:30 PM
  5. [SOLVED] sort and delete based on the values in column c and column j?
    By barbibchn in forum Excel General
    Replies: 1
    Last Post: 01-14-2013, 04:25 PM
  6. Replies: 7
    Last Post: 07-24-2010, 08:07 PM
  7. [SOLVED] Sort a multi column listbox in userform
    By Martin in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-07-2005, 05:05 PM

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