Setting ListBox.RowSource correctly with blank columns

Starkey

Board Regular
Joined
May 5, 2006
Messages
187
Hi everyone. Not posted for ages but still read the threads when I need help which I continue to find very useful

I've just discovered the RowSouce property of ListBoxes and it's opened up a wealth of new possibilities. However I'm struggling in scenarios where I want to populate a ListBox with several columns, one of which has a header but no values in it

So imagine a worksheet with 3 columns. I've inserted the headers of each of these columns in the first row (ID, Description, Data Type). I've done this because I've set the ColumnHeads property to TRUE

My data sits between rows 2 and 50. All 49 cells are populated for columns 1 (ID) and 2 (Description) but not one cell is populated for column 3 (Data Type) because it's not a mandatory field. I've set the RowSource as follows:

With Sheets("STAGING")
ListBox3.RowSource = "'" & .Name & "'!" & .Range("A2", .Cells(1048576, A).End(xlUp)).Address
End With

Where A = Application.WorksheetFunction.CountA(Sheets("STAGING").Rows("1:1")) (i.e. 3)

So I expected RowSource to be A2:C50 but instead it's A2:B2

Any idea where I'm going wrong please?

Many thanks
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney

Forum statistics

Threads
1,223,164
Messages
6,170,444
Members
452,326
Latest member
johnshaji

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