Run-time error '381': Could not set the List property. Invalid property array index. (RowSource)

jeffcdo

New Member
Joined
Jan 29, 2022
Messages
7
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
  3. Mobile
Running fine on Windows, I'm trying to get this to run on Excel for Mac. I believe the errors are coming from the syntax after the use of "RowSource"
Previously I've changed .RowSource to .List but here I don't seem to be setting the array correctly...

VBA Code:
Private Sub cmbSearch_Click()
    Dim DataRange As Range, FoundCell As Range
    Dim i, j        As Long
    Dim Search      As Variant
    Dim ws          As Worksheet
    j = 2
    Do Until Sheet2.Cells(j, 1).Value = ""
        j = j + 1
    Loop
    If j > 2 Then
    Sheet2.Activate
    For k = 2 To j - 1
    Sheet2.Rows(2).EntireRow.Delete
    Next
    End If
    Sheet1.Activate
    Set ws = ThisWorkbook.Worksheets("Sheet1")
    Search = txtSearch.Text
    If Len(Search) = 0 Then Exit Sub
    If IsNumeric(Search) Then Search = Val(Search)
    j = 2
    i = 2
    Do Until Sheet1.Cells(i, 1).Text = ""
    Set DataRange = ws.Range(ActiveSheet.Cells(i, 1), ActiveSheet.Cells(i, 8))
    Set FoundCell = DataRange.Find(Search, LookIn:=xlValues, lookat:=xlPart)
    If Not FoundCell Is Nothing Then
        Sheet2.Cells(j, 1).Value = ws.Cells(i, 1)
        Sheet2.Cells(j, 2).Value = ws.Cells(i, 2)
        Sheet2.Cells(j, 3).Value = ws.Cells(i, 3)
        Sheet2.Cells(j, 4).Value = ws.Cells(i, 4)
        Sheet2.Cells(j, 5).Value = ws.Cells(i, 5)
        Sheet2.Cells(j, 6).Value = ws.Cells(i, 6)
        Sheet2.Cells(j, 7).Value = ws.Cells(i, 7)
        Sheet2.Cells(j, 8).Value = ws.Cells(i, 8)
        j = j + 1
    End If
    i = i + 1
    Loop
    Sheet2.Activate
    j = 2
    Do Until Sheet2.Cells(j, 1).Value = ""
        j = j + 1
    Loop
    lstDisplay.RowSource = vbNullString
    lstDisplay.ColumnCount = 8
    lstDisplay.RowSource = Worksheets("DATA").Range(Worksheets("DATA").Cells(2, 1), Worksheets("DATA").Cells(j, 8)).Address
    'MsgBox Search & Chr(10) & "Record Not Found", 48, "Not Found"
End Sub

Private Sub cmdReset_Click()
Dim i As Long
i = 2
Sheet1.Activate
Do Until Sheet1.Cells(i, 1).Text = ""
i = i + 1
Loop
lstDisplay.ColumnCount = 8
lstDisplay.RowSource = Worksheets("Sheet1").Range(Worksheets("Sheet1").Cells(2, 1), Worksheets("Sheet1").Cells(i, 8)).Address
    For x = 0 To lstDisplay.ListCount - 1
      If lstDisplay.Selected(x) = True Then
         lstDisplay.Selected(lstDisplay.ListIndex) = False
      End If
   Next x
Dim txt

For Each txt In Frame2.Controls
    If TypeOf txt Is MSForms.TextBox Then
        txt.Text = ""
    End If
Next txt
End Sub

Private Sub UserForm_Initialize()
Dim i As Long
i = 2
Sheet1.Activate
Do Until Sheet1.Cells(i, 1).Text = ""
i = i + 1
Loop
lstDisplay.ColumnCount = 8
lstDisplay.RowSource = Worksheets("Sheet1").Range(Worksheets("Sheet1").Cells(2, 1), Worksheets("Sheet1").Cells(i, 8)).Address
End Sub
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
You can't use Rowsource on a mac. So you'd need:

Code:
lstDisplay.list = Worksheets("DATA").Range(Worksheets("DATA").Cells(2, 1), Worksheets("DATA").Cells(j, 8)).value
 
Upvote 0
You can't use Rowsource on a mac. So you'd need:

Code:
lstDisplay.list = Worksheets("DATA").Range(Worksheets("DATA").Cells(2, 1), Worksheets("DATA").Cells(j, 8)).value
I'm still getting an error in this area:

VBA Code:
lstDisplay.List = vbNullString
    lstDisplay.ColumnCount = 8
    lstDisplay.List = Worksheets("DATA").Range(Worksheets("DATA").Cells(2, 1), Worksheets("DATA").Cells(j, 8)).Value
 
Upvote 0
Remove the first line of those three.
 
Upvote 0
Solution

Forum statistics

Threads
1,224,823
Messages
6,181,183
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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