![]() |
macro help needed
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 |
macro help needed
You can use the Find Method in Excel VBA.
Please refer http://www.ozgrid.com/VBA/find-method.htm If this post helps click Yes --------------- Jacob Skaria "Carolina Girl" wrote: 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 |
All times are GMT +1. The time now is 03:01 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com