Problem when deleting data

Noz2k

Well-known Member
Joined
Mar 15, 2011
Messages
693
So I have my workbook, forms, macros etc all working as I want them too. Everything runs fine, until that is I delete all the made up data I was using to test the form.

When I try and add a record via the userform now, and click 'cmdsend' I get a error message saying "Run-time error '381': Could not set the List property. Invalid property array index"

I assume it's to do with the cbouniqueid.listindex but it worked before
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
Some additional information

It works fine if I leave 2 rows of data in the table.

Code:
Dim lngLastRow As Long
    lngLastRow = Cells(Rows.Count, "A").End(xlUp).Row
 
 
    cboUniqueID.List = Worksheets("Sheet1").Range("A3:A" & lngLastRow).Value

refers to the UniqueId.List
 
Upvote 0
Could this have something to do with Sheet1 being protected on .activate?

Code:
ActiveWorkbook.Sheets("Sheet1").Activate
Sheets("Sheet1").UnProtect "Password"
Range("A3").Select
Dim lngLastRow As Long
    lngLastRow = Cells(Rows.Count, "A").End(xlUp).Row
 
 
    cboUniqueID.List = Worksheets("Sheet1").Range("A3:A" & lngLastRow).Value
      Unload Me

If when the I click debug on the error and hover over 'lngLastRow' it gives me the correct value, so I don't understand what is stopping it from working, when it works if there is data in row A3 and A4.

Anyone?
 
Upvote 0
So I'm pretty sure that the problem is that effectively the .List cannot equal only 1 value, so when lngLastRow equals 3 the range = A3:A3.

How can I get around this?
 
Upvote 0

Forum statistics

Threads
1,224,506
Messages
6,179,158
Members
452,892
Latest member
yadavagiri

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