run time error 380 rowsource property invalid property value

Patriot2879

Well-known Member
Joined
Feb 1, 2018
Messages
1,259
Office Version
  1. 2010
Platform
  1. Windows
Hi good morning, Please can you help me, i get a 'Run time error 380 property invalid property value' and it highlights in yellow the line below, but i have no idea how to correct it as i cant see what the issue is
VBA Code:
.RowSource = "Data_Display!A2:K" & lr
anf this is the whole code for my listbox -
Code:
Sub Refresh_Listbox()

Dim sh As Worksheet
Set sh = ThisWorkbook.Sheets("Data")
 
Dim dsh As Worksheet
Set dsh = ThisWorkbook.Sheets("Data_Display")

''''''''''' Copy Data ''''''''''
dsh.Cells.Clear
sh.AutoFilterMode = False

If Me.cmb_Filter_By.Value <> "ALL" Then
    sh.UsedRange.AutoFilter Application.WorksheetFunction.Match(Me.cmb_Filter_By.Value, sh.Range("1:1"), 0), "*" & Me.txt_Search.Value & "*"
End If

sh.UsedRange.Copy dsh.Range("A1")

sh.AutoFilterMode = False

Dim lr As Long
lr = Application.WorksheetFunction.CountA(dsh.Range("A:A"))

If lr = 1 Then lr = 2

With Me.ListBox1
    .ColumnHeads = True
    .ColumnCount = 11
    .ColumnWidths = "20,160"
    .RowSource = "Data_Display!A2:K" & lr
End With

End Sub

Really hope you can help me please.
 
I haven't yet replicated your error. Can you give me the exact steps you take when it occurs?
 
Upvote 0

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
I haven't yet replicated your error. Can you give me the exact steps you take when it occurs?
Hiya it doesn’t happen all the time it seems to happen when the file has been open a while and not used. But it seems to happen when you’re putting in the date. If you open it and fill the form in you won’t get the error, it’s weird as only happens every so often.
 
Upvote 0
Hiya i have noticed that the error happens if you have the Userform open and click on another spreadsheet then click back to the Userform which is still open the i get the error, hope you can help me please. the error is '.Rowsource = "Data_Display!A2:K" & lr' please can you help
 

Attachments

  • Untitled.jpg
    Untitled.jpg
    54.2 KB · Views: 4
Upvote 0
Your link only refers to a worksheet name, not a workbook name. If you activate a different workbook that doesn't have a sheet by that name, you will get an error. If you need to be able to do that, you need to include the name in the rowsource:

VBA Code:
"'[workbook name.xlsm]Data_Display'!A2:K" & lr

is the basic syntax. You need the square brackets and the single quotes.
 
Upvote 1
Solution
Your link only refers to a worksheet name, not a workbook name. If you activate a different workbook that doesn't have a sheet by that name, you will get an error. If you need to be able to do that, you need to include the name in the rowsource:

VBA Code:
"'[workbook name.xlsm]Data_Display'!A2:K" & lr

is the basic syntax. You need the square brackets and the single quotes.
Hi RoryA that seems to be working now thank you for your help
 
Upvote 0

Forum statistics

Threads
1,223,856
Messages
6,175,029
Members
452,606
Latest member
jkondrat14

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