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

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).

dfenton21

Board Regular
Joined
Jun 23, 2007
Messages
135
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
 
L

Legacy 68668

Guest
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
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,163,511
Messages
5,832,175
Members
430,114
Latest member
kefier

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