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
 

Some videos you may like

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.

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
 

Watch MrExcel Video

Forum statistics

Threads
1,122,561
Messages
5,596,849
Members
414,107
Latest member
Tigretto

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