Listbox - insert values into multi columns

dave8

Active Member
Joined
Jul 8, 2007
Messages
275
I have a listbox defined as fmListStyleOption, fmMultiSelect with 2 columns. I want to insert two columns of data into the listbox. How to get this to work?


Code:
For r = 1 To 10
       If Sheets("Sheet1").Range("B" & r).Value = ComboBox1.Value Then
          ListBox2.AddItem Sheets("Sheet1").Range("B" & r).Value
          ListBox2.List(2, r) = Sheets("Sheet1").Range("C" & r).Value
       End If
     Next
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
Try something like this...

Code:
    [color=darkblue]For[/color] r = 1 [color=darkblue]To[/color] 10
        [color=darkblue]If[/color] Sheets("Sheet1").Range("B" & r).Value = ComboBox1.Value [color=darkblue]Then[/color]
            ListBox2.AddItem Sheets("Sheet1").Range("B" & r).Value
            ListBox2.List(ListBox2.ListCount - 1, 1) = Sheets("Sheet1").Range("C" & r).Value
         [color=darkblue]End[/color] [color=darkblue]If[/color]
    [color=darkblue]Next[/color]
 
Upvote 0

Forum statistics

Threads
1,216,206
Messages
6,129,496
Members
449,512
Latest member
Wabd

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top