View Single Post
  #30   Report Post  
Posted to microsoft.public.excel.programming
Claus Busch Claus Busch is offline
external usenet poster
 
Posts: 3,872
Default My Never ending ARRAY code problems

Hi Howard,

Am Fri, 13 Feb 2015 22:32:08 -0800 (PST) schrieb L. Howard:

Can't make it loop, just get the first row.


modify your macro "CompareOne":

Sub ColumnsCompareOne()

Dim i As Long, ii As Long
Dim LRow1 As Long, LRow2 As Long
Dim MyArr1 As Variant
Dim varData As Variant

LRow1 = Sheets("Sheet1").Cells(Rows.Count, "C").End(xlUp).Row
MyArr1 = Sheets("Sheet1").Range("C2:C" & LRow1)
LRow2 = Sheets("Sheet2").Cells(Rows.Count, "H").End(xlUp).Row
varData = Sheets("Sheet2").Range("A2:Z" & LRow2)

Application.ScreenUpdating = False

With Sheets("Sheet2")

For i = LBound(MyArr1) To UBound(MyArr1)
For ii = LBound(varData) To UBound(varData)
If MyArr1(i, 1) = varData(ii, 8) Then
Sheets("Sheet3").Cells(Rows.Count, 1).End(xlUp)(2) _
.Resize(, 26) = Application.Index(varData, ii, 0)
.Rows(ii + 1).Copy
Sheets("Sheet3").Cells(Rows.Count, 1).End(xlUp) _
.PasteSpecial xlPasteFormats
Exit For
End If
Next 'ii
Next 'i

End With
Application.CutCopyMode = False
Application.ScreenUpdating = True
End Sub

Or look again in OneDrive for Book3


Regards
Claus B.
--
Vista Ultimate / Windows7
Office 2007 Ultimate / 2010 Professional