My Never ending ARRAY code problems
Hi Garry,
Sure seems to me it should work, but, no errors and no results.
Code acts like it runs, but returns nothing.
Howard
Sub ColumnsC_Garry()
Dim n&, j&, lLastRow
Dim rngSource As Range
Dim i As Long, ii As Long
Dim MyArr1 As Variant
Const lStartRow& = 2
Application.ScreenUpdating = False
On Error GoTo ErrExit
lLastRow = Sheets("Sheet1").Cells(Rows.Count, "C").End(xlUp).Row
MyArr1 = Sheets("Sheet1").Range("C2:C" & lLastRow)
With Sheets("Sheet2")
lLastRow = .Cells(Rows.Count, "H").End(xlUp).Row
Set rngSource = Sheets("Sheet2").Range("H2:H" & lLastRow)
For n = lStartRow To UBound(MyArr1)
For j = lStartRow To lLastRow
If MyArr1(n, 1) = rngSource.Rows.Count Then
If rngSource Is Nothing Then
Set rngSource = .Range(.Cells(j, 1), .Cells(j, 26))
If MyArr1(i, 1) = rngSource Then
Application.Index(rngSource, ii, 0).Copy _
Sheets("Sheet3").Cells(Rows.Count, 1).End(xlUp)(2)
Else
MsgBox "no matches found"
End If 'Myrr1(i
End If 'rngSou
End If 'MyArr1(n
Next 'j
Next 'n
End With
ErrExit:
Set rngSource = Nothing
Application.ScreenUpdating = True
End Sub
|