运行时错误“ 380”无法设置行来源属性,属性值无效

时间:2019-09-20 06:06:26

标签: excel vba excel-2010

我遇到了错误

  

运行时错误'380':无法设置RowSource属性,属性值无效。

我该怎么办?

我有三个标签:FormProduct SearchStock Data

我已经在公式标签下设置了名称管理器:

=OFFSET('Product Search'!$A$2,0,0,COUNTA('Product Search'!$A:$A)-1,3)

这是我的代码:

Private Sub cmdSearch_Click()
    Dim RowNum As Long 
    Dim SearchRow As Long 

    RowNum = 2
    SearchRow = 2
    Worksheets("Product Search").Range("A2:I100").ClearContents

    Worksheets("Stock Data").Activate

    Do Until Cells(RowNum, 1).Value = ""
        If InStr(1, Cells(RowNum, 2).Value, txtKeywords.Value, vbTextCompare) > 0 Then
            Worksheets("Product Search").Cells(SearchRow, 2).Value = Cells(RowNum, 1).Value
            Worksheets("Product Search").Cells(SearchRow, 1).Value = Cells(RowNum, 2).Value
            Worksheets("Product Search").Cells(SearchRow, 3).Value = Cells(RowNum, 3).Value

            SearchRow = SearchRow + 1
        End If

        RowNum = RowNum + 1
    Loop

    If SearchRow = 2 Then
        MsgBox "No products were found that match your search criteria."
        Exit Sub
    End If

    lstSearchResults.RowSource = "SearchResults"
End Sub

0 个答案:

没有答案