Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Arrays 如何使用.EntireRow转换数组?_Arrays_Vba_Excel_Range_Transpose - Fatal编程技术网

Arrays 如何使用.EntireRow转换数组?

Arrays 如何使用.EntireRow转换数组?,arrays,vba,excel,range,transpose,Arrays,Vba,Excel,Range,Transpose,我有以下数组,它存储从搜索函数中找到的值 If FoundCells Is Nothing Then Debug.Print "Value Not Found" Else For Each FoundCell In FoundCells Array1(i) = FoundCell.Value 'Instead of .Value I can use .Row but .EntireRow doesn't work i = i + 1 Next

我有以下数组,它存储从搜索函数中找到的值

If FoundCells Is Nothing Then
    Debug.Print "Value Not Found"
    Else
    For Each FoundCell In FoundCells
    Array1(i) = FoundCell.Value    'Instead of .Value I can use .Row but .EntireRow doesn't work
    i = i + 1
    Next FoundCell
    j = i - 1
    i = 1
End If
然后,我使用转置从数组中提取数据,转置适用于“.Value”和“.Row”,但我无法通过“.EntireRow”从每个找到的值中提取整行数据

Range("A1:A" & UBound(Array1) + 1) = WorksheetFunction.Transpose(Array1)
我试图以几种方式更改范围,但似乎没有任何内容符合.EntireRow标准

loannis发表评论后更新:

如何使用数组中的EntireRow根据FoundCell中存储的搜索结果将所有行转置到目标位置


我正在使用cpearson的FindAll搜索函数,您可以像这样提取整行,但它是一个二维数组

Sub MethodName()
    Dim Array1
    'Get all the cell values in row A
    Array1 = Cells(1, 1).EntireRow
    Dim i As Integer
    'loop through the array and output the contents to the 2nd row
    For i = 1 To UBound(Array1, 2)
        Cells(2, i).Value = Array1(1, i)
    Next i
End Sub

我得出的结论是,为了达到我这样做的目的,我不妨废弃阵列,这样做:

If FoundCells Is Nothing Then
    Debug.Print "Value Not Found"
    Else
    For Each FoundCell In FoundCells
    FoundCell.EntireRow.Copy Worksheets("Sheet3").Range("A" &   Rows.Count).End(xlUp).Offset(1)
    Next FoundCell

End If

谢谢你的回答。我正在使用CPearson中的FindAll函数,我还不确定当我的数组找到多个搜索结果时如何使用它。这是对。此外,你对下面答案的评论似乎是另一个问题。您想要实现什么?在我的问题中,我可能没有充分指出,我想要基于存储在数组1中的多个搜索结果转置所有行。我会更新我的问题。据我所知,我不能用魔法的密码来做这件事。但也许我错了。