Best Way to load a listbox using a combobox

gmazza76

Well-known Member
Joined
Mar 19, 2011
Messages
771
Office Version
  1. 365
Platform
  1. Windows
Good Evening,

I use a userform to display set info from a stats sheet.

I am having an issue where i get a listbox to populate with set data.
ie if the combobox is selected as John i want it show data in the list box for A1:D3 etc.

I am using the following VB but am having issues on how to repeat the listbox info depending on the combobox selection

Rich (BB code):
Dim wbData As Workbook
Dim StatsCW As Worksheet
 
Application.ScreenUpdating = False
 
Set wbData = Workbooks.Open
(Filename:="C:\Users\MAZZA\Documents\Gavin\Car Park\Data.xls")  'Home
'Set wbData = Workbooks.Open(Filename:="\\W2K6082\COMMON\SHARED\Gavin Mazza\Car Park\Data.xls")
Set StatsCW = wbData.Worksheets("Stats CW")
    If MgrCheckCW.ComboBox1 = "BS1" Then
    
        With StatsCW.Range("C4:O19")
            ListBox1.ColumnCount = .Columns.Count
            ListBox1.List = .Value
        End With

    End If
 Next
    If MgrCheckCW.ComboBox1 = "HF1" Then
     
         With StatsCW.Range("C22:O37")
             ListBox1.ColumnCount = .Columns.Count
             ListBox1.List = .Value
         End With
     End If
End Sub
Any help will be great.
Cheers
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)

Forum statistics

Threads
1,224,521
Messages
6,179,291
Members
452,902
Latest member
Knuddeluff

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