View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Rick Rothstein \(MVP - VB\)[_2215_] Rick Rothstein \(MVP - VB\)[_2215_] is offline
external usenet poster
 
Posts: 1
Default Fill ListBox as per number of Records in the sheet.

Do not set the RowSource in the Properties box, set it in code instead. Try
using something like this in your UserForm_Initialize event...

Dim LastRow As Long
LastRow = Worksheets("Sheet1").Cells(Rows.Count, "A").End(xlUp).Row
ListBox1.RowSource = "A1:H" & LastRow

Rick


"Shazi" wrote in message
...
Hi,

I have a ListBox1 which is connected to the "DailyPurchase" worksheet,
I set the RowSource : DailyPurchase!A5:H2000.

DailyPurchase sheet is updated daily basis at least 20 entries per
day.
and my DailyPurchase sheet have 200 records at present, and its
increasing day by day.

the problem is this when I load the userform it shows lot of blank
rows at bottom in the listbox, which I dont want to see.

I want to see only current entries/records in the ListBox. if I add
20 or more than 20 records per day, the listbox shows the actual
records in the listbox.

If any one knows how to do this pls help me out.

Best Regards.


Syed Shahzad Zafar
Madinah