Try this code. It highlights each row that is added in green. You have to
modify the code by changing MyPath. Also you need to change the AcntNumCol
to be the correct column in your worksheet. I assumed there was a header row
in each worksheet so the code skips row 1.
Sub mergeaccounts()
Const MyPath = "c:\temp\test\"
Const AcntNumCol = "B"
AcntRange = AcntNumCol & "2:" & AcntNumCol
MergeBooks = Array("CVM 1.xls", "CVM 5.xls", _
"Eradicates.xls")
ShNames = Array("535", "536", "537")
For Each wkb In MergeBooks
Workbooks.Open Filename:=MyPath & wkb
For Each wksname In ShNames
With ThisWorkbook.Sheets(wksname)
LastRowEKnow = .Cells(Rows.Count, AcntNumCol). _
End(xlUp).Row
Set EknowRange = .Range(AcntRange & LastRowEKnow)
End With
With ActiveWorkbook.Sheets(wksname)
LastRowwkb = _
.Cells(Rows.Count, AcntNumCol). _
End(xlUp).Row
Set wkbRange = _
.Range(AcntRange & LastRowwkb)
For Each cell In wkbRange
If Not IsEmpty(cell) Then
Set c = EknowRange.Find(what:=cell, _
LookIn:=xlValues)
cell.EntireRow.Copy
With ThisWorkbook.Sheets(wksname)
If Not c Is Nothing Then
'found item add below found item
.Rows(c.Row + 1). _
Insert Shift:=xlDown
.Rows(c.Row + 1). _
Interior.ColorIndex = 10
Else
'not found add to end of list
.Rows(LastRowEKnow + 1). _
Insert Shift:=xlDown
.Rows(LastRowEKnow + 1). _
Interior.ColorIndex = 10
End If
LastRowEKnow = _
LastRowEKnow + 1
Set EknowRange = _
.Range(AcntRange & LastRowEKnow)
End With
End If
Next cell
End With
Next wksname
Workbooks(wkb).Close
Next wkb
End Sub