Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

populating list box from worksheet 1

Status
Not open for further replies.

johnny45

Technical User
Nov 8, 2006
136
CA
I'm populating a listbox as follows:
Code:
With Sheet1
Me.lbxCustomers.List = .Range(.[B2], .Cells(Rows.Count, 2).End(xlUp)).value
end with

Sheet 1 has a HEADING ROW
if sheet 1 JUST has the Heading Row, the listbox gets populated with the heading row - Should it just be empty ?

if sheet 1 has 1 row of data I get an error
if sheet 1 has 2 or more rows of data it works fine

how can I fix ?
 



Hi,

I perfer to use named range.

But...
Code:
    With Sheet1
      Select Case .[B1].CurrentRegion.Rows.Count
        Case 2
            Me.lbxCustomers.RowSource = .[B2].Address
        Case Is > 2
            Me.lbxCustomers.RowSource = .Range(.[B2], .[B2].End(xlDown)).Address
      End Select
    End With


Skip,

[glasses] When a diminutive clarvoyant had disappeared from detention, headlines read...
Small Medium at Large[tongue]
 
Thanks Skip !

Cheers and the Very Best for the New Year !
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top