PDA

View Full Version : Listbox Question



dfenton21
03-16-2009, 04:39 PM
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.

If that can't be done, what is the VBA code to only copy and paste the cells in A with 2009 in B

I have used a similar code to send emails to certain address only, but I'm not sure how to edit it for this purpose.

Thanks,
Damien

Bob Phillips
03-16-2009, 05:00 PM
You need to build the Listbox, bot bind it



Private Sub Userform_Initialize()

For Each cell In Range("A2:A20")

If cell.Offset(0,1).Value = 2009 Then

ListBox1.AddItem cell.Value
End If
Next cell

End Sub