VBA - Need to search through a list of IDs for a select range of IDs

iancook1982

New Member
Joined
Jun 14, 2010
Messages
13
Hi,

I have a list of IDs, say there are 20 of them (that vary) on one sheet (called "ID List"). I need to use this range and search for each ID within a larger sheet of data called ("Estimated Data Log"). What I want is for the code to search for each example of an ID within the log, when it finds one to then copy the row and paste it onto "Sheet1", then to continue searching for each ID, as they will appear multiple times in the Log data. Once it has searched the log I'd like it to move onto the next ID in the ID List and repeat the process.

I've tried using FindAll, Find & Find Next and can't seem to get it to work.

Can you help?

Thanks,
Ian.
 
We don't know much about where things are on these sheets, but see if you can use/adapt this. I have assumed ..

1. On 'ID List' the ID codes are in column A starting at row 2.

2. On 'Estimated Data Log' the IDs are in column D but data starts in column A and there is a heading row on the sheet.

Test in a copy of your workbook.

<font face=Courier New><br><SPAN style="color:#00007F">Sub</SPAN> CopyIDs()<br>    <SPAN style="color:#00007F">Dim</SPAN> wsEDL <SPAN style="color:#00007F">As</SPAN> Worksheet, wsIDL <SPAN style="color:#00007F">As</SPAN> Worksheet, wsSh1 <SPAN style="color:#00007F">As</SPAN> Worksheet<br>    <SPAN style="color:#00007F">Dim</SPAN> c <SPAN style="color:#00007F">As</SPAN> Range<br>    <br>    <SPAN style="color:#00007F">Set</SPAN> wsEDL = Sheets("Estimated Data Log")<br>    <SPAN style="color:#00007F">Set</SPAN> wsIDL = Sheets("ID List")<br>    <SPAN style="color:#00007F">Set</SPAN> wsSh1 = Sheets("Sheet1")<br>    Application.ScreenUpdating = <SPAN style="color:#00007F">False</SPAN><br>    <SPAN style="color:#00007F">For</SPAN> <SPAN style="color:#00007F">Each</SPAN> c <SPAN style="color:#00007F">In</SPAN> wsIDL.Range("A2", wsIDL.Range("A" & Rows.Count).End(xlUp))<br>        <SPAN style="color:#00007F">With</SPAN> wsEDL.UsedRange<br>            .AutoFilter Field:=4, Criteria1:=c.Value<br>            .Offset(1).Copy _<br>                Destination:=wsSh1.Range("A" & Rows.Count).End(xlUp).Offset(1)<br>        <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">With</SPAN><br>    <SPAN style="color:#00007F">Next</SPAN> c<br>    wsEDL.AutoFilterMode = <SPAN style="color:#00007F">False</SPAN><br>    Application.ScreenUpdating = <SPAN style="color:#00007F">True</SPAN><br>End <SPAN style="color:#00007F">Sub</SPAN><br></FONT>
 
Upvote 0
That's great Peter Thanks. Only needed a slight tweak on the locations but other than that it's excellent.

Many Thanks,
Ian.
 
Upvote 0

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top