Populate cells from list box drag/drop, can't find first empty row on worksheet

C4Vicious

New Member
Joined
Jun 18, 2013
Messages
13
Hello,

I am running Excel 2010 and Windows 7.


I have been working on this project for several weeks and this problem has eluded me from nearly the beginning.

See Photo

I have a form with a main list box and several other list boxes. I drag and drop records from the main list box to the others. When I drop a record onto one of the list boxes, a corresponding worksheet is updated with the same record. This works just fine.

The problem I have is:
  • I close and re-open the form after having added some data
  • Drag/Drop a record to the list box
  • The worksheet won't find the first empty row
  • Example: If the worksheet already contains 4 rows of data, I have to drag/drop 5 times before the fifth row will be updated
  • I would like to drop the data the first time and have the first blank row updated

Notes:
1.) I have tried variations of "xlUp", "xlDown", and SpecialCells(xlCellTypeLastCell) in the "Worksheets("Monday")... line of code; all to no avail.

2.) The cells contain formatting (borders)

Here is the relevant code:

Code:
'Copy items from the list box to the worksheet
    For intI = 1 To ListBox2.ListCount
        For intJ = 1 To ListBox2.ColumnCount
            If IsEmpty(Worksheets("Monday").Cells(intI + 1, intJ)) Then
                Worksheets("Monday").Cells(intI + 1, intJ).Value = ListBox2.List(intI - 1, intJ - 1)
            End If
        Next intJ
    Next intI

Any help is much appreciated.
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().

Forum statistics

Threads
1,223,240
Messages
6,170,951
Members
452,368
Latest member
jayp2104

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