Fill a ListBox with extracted data

jimayers

Board Regular
Joined
Nov 14, 2010
Messages
99
Hello, can anybody help with this?
I have a list box that I want populated by extracted date from this code:
Code:
Sub Listing_Cousrse_Titles()
Application.ScreenUpdating = False
Dim r, a, Lastrow As Long
Lastrow = Cells(Rows.Count, "A").End(xlUp).Row
a = 6
If Cells(a, 37) <> xlnull Then
    MsgBox ("Proceedure already performed.")
    Exit Sub
End If
For r = 1 To Lastrow
    If Cells(a, 37) <> xlnull Then a = a + 1
    If Cells(r, 1) = "COURSE TITLE:" Then Cells(a, 37) = Cells(r, 3)
    If Cells(a, 37) = Cells(a - 1, 37) Then Cells(a, 37).Delete
Next r
Application.ScreenUpdating = True
End Sub
The above produces a list of about 12 course titles in column 37, and are what I want added to my list box.
I thought that maybe I should insert .Additem something like this:
Code:
Sub Listing_Cousrse_Titles()
Application.ScreenUpdating = False
Dim r, a, Lastrow As Long
Lastrow = Cells(Rows.Count, "A").End(xlUp).Row
a = 6
If Cells(a, 37) <> xlnull Then
    MsgBox ("Proceedure already performed.")
    Exit Sub
End If
For r = 1 To Lastrow
    If Cells(a, 37) <> xlnull Then a = a + 1
    If Cells(r, 1) = "COURSE TITLE:" Then Cells(a, 37) = Cells(r, 3)
        [SIZE=3][B]Sheets(1).listbox1.additem(cells(r, 3).value)[/B][/SIZE]
    If Cells(a, 37) = Cells(a - 1, 37) Then Cells(a, 37).Delete
Next r
Application.ScreenUpdating = True
End Sub
I have yet to get it to work. Any help would be appreciated - thanks - Jim A
 

Some videos you may like

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,219
Office Version
  1. 365
Platform
  1. Windows
How did you create the listbox?
 

Watch MrExcel Video

Forum statistics

Threads
1,123,172
Messages
5,600,128
Members
414,365
Latest member
UUR

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
Top