Welcome. I'm trying to copy data from several specific sheets to the main one. But I'm having a problem copying data over each other. Can you please correct the error?
Is there a possibility to add another condition so that all sheets in row 9, starting from column U, are searched for the value of cell M2 Sheet2 and fetch the values corresponding to the search value R12?
Is there a possibility to add another condition so that all sheets in row 9, starting from column U, are searched for the value of cell M2 Sheet2 and fetch the values corresponding to the search value R12?
VBA Code:
Sub EssaiFiltreArrayClé()
Dim f As Variant
Dim ws As Worksheet: Set ws = Sheets("Sheet2")
Clé = ws.[R12]
Dim wsArray As Variant: wsArray = Array("Sheet1", "Sheet2", "Sheet3")
For Each f In Worksheets(wsArray)
Tbl1 = f.Range("c10:t" & f.[c65000].End(xlUp).Row).Value
For i = 1 To UBound(Tbl1)
If Tbl1(i, 16) = Clé Then n = n + 1
Next i
j = 0
Dim Tbl2(): ReDim Tbl2(1 To n, 1 To UBound(Tbl1, 2))
For i = 1 To UBound(Tbl1)
If Tbl1(i, 16) = Clé Then j = j + 1: For k = 1 To UBound(Tbl1, 2): Tbl2(j, k) = Tbl1(i, k): Next k
Next i
ws.[C14].Resize(UBound(Tbl2), UBound(Tbl2, 2)) = Tbl2
Next f
End Sub