Listbox Question

dfenton21

Board Regular
Joined
Jun 23, 2007
Messages
135
Hi All,

I am making a form that contains a list box. I know how to specify the source but I want to do this:

I have two columns (A & B). A contains a list of invoice numbers and B contains the year of the invoice. Is it possible to select A as the source for the list box, but only use the cells that have 2009 in column B.

Thanks,
Damien
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
If this can't be done, is it possible to copy and paste only the cells in A that has 2009 in B. I have a piece of VBA that can send emails this way, but I can't figure out how to modify it for this purpose.

Thanks,
Damien
 
Upvote 0
Delete RowSource from the property box and paste the code onto your userform module
Rich (BB code):
Private Sub UserForm_Initialize()
Dim r As Range
With Sheets("YourSheetNameHere")  '<- change the sheet name
    With Range("a1").CurrnetRegion.Resize(, 1)
        For Each r In .Cells
            If r.Offset(, 1).Value = 2009 Then _
                Me.ListBox1.AddItem r.Value
        Next
    End With
End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,606
Messages
6,120,487
Members
448,967
Latest member
visheshkotha

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