PDA

View Full Version : Solved: Loop through two worksheets



Gunilla
08-28-2011, 01:48 AM
Hi
I know I have seen the solution to this, but of course when I need it I can't find it.:cuckoo:
I have a workbook with 2 worksheets. On worksheet 1 I have about 1500 names(Customers) on worksheet 2 I have about 500 (payments) names.
How do I loop through worksheet 2 to make sure that those who are listed on Worksheet 1 gets credit for the payment? The payment is listed in column "J".

Bob Phillips
08-28-2011, 06:47 AM
Off the top



With Worksheets("Sheet2")

For Each cell In .Range(.Range("A2"), .Range("A2").End(xlDown))

MatchRow = 0
On Error Resume Next
MatchRow = APplication.Match(cell.Value, Worksheets("Sheet1").Columns(1),0))
On Error Goto 0
If MatchRow > 0 Then

cell.Offset(0, 1).Value = Worksheets("Sheet1").Cells(MatchRow, "J").Value
End If
Next cell
End With

Gunilla
08-28-2011, 09:11 AM
Exactly what I want. I will store it in a safe place.
:clap2:
Thank you