0

I have a form where I want to populate two listboxes with the data stored in Roses and Customers worksheets. The line of code bwith the ** below is what is giving me trouble.

Private Sub UserForm_activate()

    Application.Workbooks("xx.xlsm").Activate

    ActiveWorkbook.Worksheets("Customers").Range("B2").Select
    Do Until IsEmpty(ActiveCell) = True
    'loop through the customer table list
        lstCustomers.AddItem ActiveCell.Value
        ActiveCell.Offset(1, 0).Select
    Loop

    *****ActiveWorkbook.Worksheets("Roses").Range("A3").Select
    Do Until IsEmpty(ActiveCell) = True
    'loop through the roses table list
        lstProducts.AddItem ActiveCell.Value
        ActiveCell.Offset(1, 0).Select
    Loop

End Sub

Error: Select method of range class failed

What am I doing wrong?

Community
  • 1
  • 1
user2896819
  • 65
  • 2
  • 5

1 Answers1

0

Select the worksheet and cell sequentially rather than in a single line.

Do not use IsEmpty() to test for an un-filled cell. Rather use ActiveCell.Value=""

Gary's Student
  • 95,722
  • 10
  • 59
  • 99