My Never ending ARRAY code problems
On Friday, February 13, 2015 at 9:48:52 PM UTC-8, L. Howard wrote:
Hi Garry,
This does copy the first and only the first match and the formatting.
Can't make it loop, just get the first row.
Howard
Sub ColumnsC_Garry()
Dim n&, j&, lLastRow
Dim rngSource As Range
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(j) Then '.Rows.Count Then
' If rngSource Is Nothing Then
Set rngSource = .Range(.Cells(j, 1), .Cells(j, 26))
' If MyArr1(n, 1) = rngSource(j) Then
rngSource.Copy _
Sheets("Sheet3").Cells(Rows.Count, 1).End(xlUp)(2)
' Else
' MsgBox "no matches found"
End If 'Myrr1(n
' End If 'rngSou
' End If 'MyArr1(n
Next 'j
Next 'n
End With
ErrExit:
Set rngSource = Nothing
Application.ScreenUpdating = True
End Sub
|