davedave24
Programmer
xpost from ozgrid
'lo. I have a multicolumn listbox - the first 2 columns are filled from A and B from the worksheet. When the user selects a customer name (from a combobox), I need to load that particular customer's price list into column 3 of the listbox. The prices are stored on one sheet (ListProducts), in columns C onwards.
Here is my code and where it dies:
As you can see it gets an error on the .additem line. When I mouseover 'cell.Value', it returns the customer name (which would be the first cell). Ideally I want to not add the customer name in row 1, but add everything below that.
Any ideas?
'lo. I have a multicolumn listbox - the first 2 columns are filled from A and B from the worksheet. When the user selects a customer name (from a combobox), I need to load that particular customer's price list into column 3 of the listbox. The prices are stored on one sheet (ListProducts), in columns C onwards.
Here is my code and where it dies:
Code:
Dim rngFind As Range
[COLOR=#4E9A06] 'Find the cell containing the customer name in row 1[/color]
With ThisWorkbook.Sheets("ProductList").Range("A1:EE1")
Set rngFind = .Find(comboCustomer, , xlValues)
End With
Dim cell As Range
Dim Rng As Range
[COLOR=#4E9A06]'load that column until we hit a blank cell[/color]
With ThisWorkbook.Sheets("ProductList")
Set Rng = .Range(rngFind.Address, .Range(rngFind.Address).End(xlDown))
End With
[COLOR=#4E9A06]'add the column to column2 of the listbox[/color]
For Each cell In Rng.Cells
With Me.listProducts
[COLOR=#CC0000].AddItem cell.Value ''ERROR - Permission Denied''[/color]
.List(.ListCount - 1, 2) = cell.Offset(0, 1).Value
End With
Next cell
As you can see it gets an error on the .additem line. When I mouseover 'cell.Value', it returns the customer name (which would be the first cell). Ideally I want to not add the customer name in row 1, but add everything below that.
Any ideas?