Consulting

Results 1 to 5 of 5

Thread: Combo Box selection = 2 values set

  1. #1
    VBAX Regular
    Joined
    Sep 2016
    Posts
    6
    Location

    Post Combo Box selection = 2 values set

    Hello. I want to have 2 values getting set when i select a single line from a combo box.

    I got my example from excel-easy.com/vba/examples/multicolumn-combo-box.html=

    My code is here: pastebin.com/FwuaqcDf

    So basically when i select the first line from the ComboBox

    With Pclient
    Pclient.ColumnCount = 2
    Dim Client(1 To 15, 1 To 2) As String
    
    Client(1, 1) = "CMN"
    Client(2, 1) = "RSS"
    Client(3, 1) = "ORD"
    Client(4, 1) = "CEB"
    Client(5, 1) = "GP-BE"
    Client(6, 1) = "GP-ME"
    Client(7, 1) = "MSL"
    Client(8, 1) = "SSO"
    Client(9, 1) = "SSO-QTE"
    Client(10, 1) = "FZH"
    Client(11, 1) = "BPO"
    Client(12, 1) = "RAB"
    Client(13, 1) = "E&D"
    Client(14, 1) = "DEI"
    Client(15, 1) = "CTD"
    
    Client(1, 2) = "LSR000"
    Client(2, 2) = "LSR000"
    Client(3, 3) = "LSR002"
    Client(4, 4) = "LSR051"
    Client(5, 5) = "LSR001"
    Client(6, 6) = "LSR001"
    Client(7, 7) = "LSR007"
    Client(8, 8) = "LSR005"
    Client(9, 9) = "LSR005"
    Client(10, 10) = "LSR014"
    Client(11, 11) = "LSR027"
    Client(12, 12) = "LSR003"
    Client(13, 13) = "LSR042"
    Client(14, 14) = "LSR041"
    Client(15, 15) = "LSR040"
    
    Pclient.List = Client
    End With
    i want the values to complete in these columns based on the selection


    • Cells(ActiveCell.Row, 2).Value = Pclient.Value
    • Cells(ActiveCell.Row, 3).Value = Pclient.Column(1).Value



    But i get a error saying "Run-time error '9' subscript out of range"

    Any tips on what i'm doing wrong?

  2. #2
    VBAX Expert
    Joined
    May 2016
    Posts
    604
    Location
    [QUOTE
    Dim Client(1 To 15, 1 To 2) As String
    
    Client(3, 3) = "LSR002"
    Client(4, 4) = "LSR051"
    Client(5, 5) = "LSR001"
    Client(6, 6) = "LSR001"
    Client(7, 7) = "LSR007"
    Client(8, 8) = "LSR005"
    Client(9, 9) = "LSR005"
    Client(10, 10) = "LSR014"
    Client(11, 11) = "LSR027"
    Client(12, 12) = "LSR003"
    Client(13, 13) = "LSR042"
    Client(14, 14) = "LSR041"
    Client(15, 15) = "LSR040"
    [/QUOTE]

    You have defined an 2 dimensional array "client" size 15 times 2 and then tried to use as a 15 times 15 array

  3. #3
    VBAX Regular
    Joined
    Sep 2016
    Posts
    6
    Location
    I feel stupid

    now i get a error on

    Cells(ActiveCell.Row, 3).Value = Pclient.Column(1).Value

  4. #4
    VBAX Expert
    Joined
    May 2016
    Posts
    604
    Location
    try
    [vba]
    Cells(ActiveCell.Row, 3).Value = Pclient.Column(1)[/vba]

  5. #5
    VBAX Regular
    Joined
    Sep 2016
    Posts
    6
    Location
    it worked thank you!

Tags for this Thread

Posting Permissions

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