Albert,
Thank you for that code. It does indeed solve the problem.
I haven't yet tried it but my guess is that the copying of the range to AA1 and then its use as the RowSource for ListBox1 could be eliminated if one assigned the range to an array and then assigned that to ListBox1.
This whole question is someone else's issue. I provided a solution which omitted the column headings but worked nonetheless. It was really for my interest that I raised this question. Originally the questioner had the address information in a non-contiguous range and I used your approach to assemble a range which could be used and assigned to ListBox1. However ListBoxes won't accept non-contiguous ranges. Apart from which I hadn't then taken the next logical step to assemble a new dependant range from the first one. The long and the short of it was that I'd gone down a blind-alley and needed a fresh approach - for which many thanks.
Patrick
Main Topics
Browse All Topics





by: ahammarPosted on 2009-10-11 at 19:49:25ID: 25548392
Hi Patrick,
s("AA:BQ") .ClearCont ents
The way I understand it the only way to put headers in your listbox is to make the rowsource of the listbox = to the source range - the top row. The top row is automatically used for the headers.
So the only way to do that is to get all your address rows that you need listed in 1 contigious range, including the row with the headers at the top, then set the rowsource property of listbox2 to that range, but don't include the first row with the headers. I don't think you can use AddItem.
I wrote the code to do that. I will post it here. It replaces the code in your Listbox1 click event.
There are a lot of comments just to kinda explain what is going on so it's not really this long.
There is one line of code you will need to add in the form initialization event at the very end. Here is that line. It clears the second list box when the form opens...
Sheets("Addresses").Column
You'll see why that is necessary when you read the comments in the code for your listbox 1.
It's the only way I could find to do it, but there might be another way, but I doubt it...
I didn't upload the workbook because I made too many changes to the addresses while I was testing
Here is that code:
Just replace what you have in you listbox 1 click event with this: (It'll be much shorter when you rid the comments)
Select allOpen in new window