concatentaion的无效过程调用或参数

时间:2017-05-19 09:51:00

标签: excel vba

我在MS-Excel中运行vba脚本时遇到错误

  

无效的过程调用或参数

以下是我的代码

代码

Sub FindValues(ByVal WhereToFind As Range, ByVal WhereToPaste As Range)
    'where to find should have the header and values
    Dim col As Integer  'loop through columns
    Dim row As Integer  'loop through rows
    Dim a() As Variant
    Dim b() As Variant
    Dim i As Integer

    a() = WhereToFind

    For row = 2 To UBound(a, 1)
    For col = 2 To UBound(a, 2)
        If a(row, col) = "X" Then
          i = i + 1
          ReDim Preserve b(1 To i)
          b(i) = a(1, col) & "=" & a(row, 1)
        End If
      Next
    Next
    WhereToPaste.Resize(UBound(b)).Value = Application.Transpose(b()) // getting error on this line
End Sub

来电方式

Sub caller()
FindValues ThisWorkbook.Sheets("Sheet1").Range("A1:E4"), ThisWorkbook.Sheets("Sheet1").Range("F1")
End Sub

0 个答案:

没有答案