Consulting

Results 1 to 3 of 3

Thread: Populate Listbox in "alpabetic order"

  1. #1
    VBAX Tutor
    Joined
    Jan 2008
    Posts
    266
    Location

    Populate Listbox in "alpabetic order"

    This should be a simple task but I can't figure out what I'm not doing.

    I have a add-in macro that allows users to choose their own settings.
    The settings are saved in a file called Settings2.csv

    As an example, these are my settings:

    time,lat,lon,hMSL,velN,velE,velH,velD,vel3D,Glide,hDistance,Angle,hAcc,vAcc ,sAcc,gpsFix,numSV,AirTime
    C,A,B,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,D
    V,V,V,V,H,H,V,V,V,V,V,V,H,H,H,H,H,V
    N,N,N,B,N,N,B,B,B,B,B,B,N,N,N,N,N,B
    time,lat,lon,Altitude,velN,velE,velH,velD,vel3D,Glide,hDistance,Angle,hAcc, vAcc,sAcc,gpsFix,numSV,AirTime

    The settings are:
    Original name
    Column letter
    Visible/Hidden (V/H)
    Normal/Bold (N/B)
    Own name

    I read these settings to a array called FinalArray(4,17).
    All the code to open, save, create the file, read, write, etc. the settings is working.
    The only thing I can not do is populate the listbox in the correct order.

    In the example above the code would be:

    With UserForm5.ListBox1
        .AddItem FinalArray(4, 1)
        .AddItem FinalArray(4, 2)
        .AddItem FinalArray(4, 0)
        .AddItem FinalArray(4, 17)
        .AddItem FinalArray(4, 3)
        .AddItem FinalArray(4, 4)
        .AddItem FinalArray(4, 5)
        .AddItem FinalArray(4, 6)
        .AddItem FinalArray(4, 7)
        .AddItem FinalArray(4, 8)
        .AddItem FinalArray(4, 9)
        .AddItem FinalArray(4, 10)
        .AddItem FinalArray(4, 11)
        .AddItem FinalArray(4, 12)
        .AddItem FinalArray(4, 13)
        .AddItem FinalArray(4, 14)
        .AddItem FinalArray(4, 15)
       .AddItem FinalArray(4, 16)
    End With
    This is because it should grab the "Own name" and place them in the order Column A-Column R

    I guess I need a vlookup in the array but as far as I'm aware that is not possible.
    Anyone that can point me in the correct direction with this?

  2. #2
    Knowledge Base Approver VBAX Wizard
    Joined
    Apr 2012
    Posts
    5,646
    ListBox1.list=application.transpose(application.index(finalarray,4,array(1,2,0,17,3,4,5,6,7,8,9,10,11,12,13,14,15,16)))




  3. #3
    VBAX Tutor
    Joined
    Jan 2008
    Posts
    266
    Location
    I can't test it now because I'm at work.
    But by the looks of the code it seems to only work in the specific order I gave as an example.

    Or am I reading the code wrong?

Posting Permissions

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