Error 380 - ListIndex Property

AlanAnderson

Board Regular
Joined
Jun 7, 2010
Messages
134
Hi all,

I am using Excel 2003 running on XP.

I have a routine that allows me to work on data held within a list created from data on a spreadsheet ("Income"). This works perfectly when there is data in the sheet.
If the data sheet is empty (like after month end) then I get the following error relating to the line "ListIndex=1":


"Run time error 380"
"Could not set the ListIndex property. Invalid property value."

The bit of code where this "falls over" is listed below.
Code:
With Me.ListBox1
.BoundColumn=2
.ColumnCount=10
.ColumnHeads=True
.TextColumn=True
.RowSource="Income!B13:K" & FinalRow
.ListStyle=fmListStyleOption
.ListIndex= 1
End With

I think I need some form of "if" loop to load up empty lists so that the user can add new items but don't know where to start.

Can anyone please help?

Regards,

Alan
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
note that listindexes start at 0 not 1... so your code will get the second item

Code:
With Me.ListBox1
    .BoundColumn=2
    .ColumnCount=10
    .ColumnHeads=True
    .TextColumn=True
    .RowSource="Income!B13:K" & FinalRow
    .ListStyle=fmListStyleOption
    if finalrow>13 then .ListIndex= 1
End With
 
Upvote 0
yes, if range does not cantain any data, it would through Error.

check whether the range have data or not, if there is no data execute next line of code.

can use 'On error resume next'
 
Upvote 0
Try removing the line

Code:
.ListIndex= 1

And see if you still get your desired result
 
Upvote 0

Forum statistics

Threads
1,214,790
Messages
6,121,607
Members
449,037
Latest member
Arbind kumar

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