Run time error '380': Could not set RowSource property. Invalid property value

bdautrich

New Member
Joined
Sep 22, 2022
Messages
19
Office Version
  1. 2013
Platform
  1. Windows
Working on Excel VBA app. And I am getting an error I can not figure out.

The app is displaying a range from a spreadsheet in a list box on a user form, The first time it does this, things work fine. The user form has some text input boxes that allows the user to input a new row of data unto the spreadsheet. After the user clicks on the save button the VBA code calls the subroutine to reset the list box and the second time through, I get the 380 error. I put in a msgBox to see that the only parameter which is the row number of the last row is valid and it is so I do not have an idea what is happening. The strange this I have nearly identical VBD code that works the same way with a different spreadsheet, and I am not experiencing the error there.

Here is the code that

MsgBox ("In reset and iRow = " & iRow)

If iRow > 1 Then

.lstJoints.RowSource = "List1!A2:I" & iRow ' this is the line that generates the error

Else

.lstJoints.RowSource = "List1!A1:I1"

End If

Any help would greatly be appreciated.
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Are there any error values on the worksheet?
 
Upvote 0
Are you sure iRow is valid when the error occurs? How is it declared and what is its actual value?
 
Upvote 0
I am printing out iRow and it is a valid value and it is declared as integer.
Are you sure iRow is valid when the error occurs? How is it declared and what is its actual value?
 
Upvote 0
I can't replicate your error if the address is valid. If the sheet name is wrong, or the row number is missing, then you would get that error. Does the Else part of the If code work if you make iRow equal 1?
 
Upvote 0
Solution
I set IRow to 1 and the else part of statement worked. I then used the same code as the else statement with iRow > 1 and it worked. I changed it to A2:I2 and it worked and then I change the I2 to I concatenated with iRow and it now works. The only thing I can think of it somehow a non visible character was in the code somewhere throwing the reference off. Thanks for your help.
 
Upvote 0

Forum statistics

Threads
1,223,896
Messages
6,175,263
Members
452,627
Latest member
KitkatToby

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