macro help needed

C

Carolina Girl

HELP!!!! I have a macro that will go basically sheet by sheet and do a lookup
to find a date. The macro works great but takes a very long time to run and I
need to add about another 25 sheet to the end. Is there a way to write this
so it check each sheet between and run it a little faster?

Sub populate()

With Sheets("Linda Master List")
lastRow1 = .Cells(.Rows.Count, "A").End(xlUp).Row
End With
With Sheets("ADT Test (03.16.09)")
lastRow2 = .Cells(.Rows.Count, "A").End(xlUp).Row
End With

For i = 2 To lastRow1

k = 2
For j = 2 To lastRow2
If Sheets("Linda Master List").Cells(i, 1).Value = Sheets("ADT Test
(03.16.09)").Cells(j, 1).Value Then
Sheets("Linda Master List").Cells(i, k).Value = Sheets("ADT Test
(03.16.09)").Cells(j, 2).Value
k = k + 1
End If
Next j
Next i

With Sheets("Linda Master List")
lastRow1 = .Cells(.Rows.Count, "A").End(xlUp).Row
End With
With Sheets("PH1 WV1")
lastRow2 = .Cells(.Rows.Count, "A").End(xlUp).Row
End With

For i = 2 To lastRow1

k = 2
For j = 2 To lastRow2
If Sheets("Linda Master List").Cells(i, 1).Value = Sheets("PH1
WV1").Cells(j, 1).Value Then
Sheets("Linda Master List").Cells(i, k).Value = Sheets("PH1 WV1").Cells(j,
2).Value
k = k + 1
End If
Next j
Next i
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top