copy if data matches

E

elky.man

I have two excel workbooks that are generated on a daily basis. What
I would like to do is find out if information on todays workbook is a
match with information on the previous days workbook and if it is I
want to copy the matching information from a 3rd column and place it
in todays workbook.

The workbooks have the same format
(old workbook) (new
workbook)
Info to copy ticket number copy here ticket
number
---------------- -------------------
------------- -------------------
19809 5550157 5499795
19798 5624887 5786878
5499695 5550157
5499691 5079389
5499693
19773 5499698

As you can see the length of the ticket number column is different
every day it may have 1 item in it or 1000. As you can see ticket
number 5550157 matches in both workbooks, so I need to copy 19809 into
the new workbook and put them in the row that matches 5550157. Of
course these numbers are not constant, but they are unique to each
days work. So if 5550157 shows up on the previous day and today's
workbook it is the only time it shows up, there are not mulitple
instances of that check number in the report. I would like to use a
macro to run this match with no interaction from the end user. I have
tried to use offset to make dynamic ranges and using match but can't
figure out how to actually copy the data from a different column if
there is actually a match.

I hope that this is clear.

-Chris
 
D

Dan R.

Here's an example:

Sub test()
For Each cell In Range("A1:A50")
Set found = Range("B1:B50").Find( _
What:=cell.Value, _
LookIn:=xlValues)
If Not found Is Nothing Then
cell.Copy found.Offset(, 1)
End If
Next cell
End Sub
 
E

elky.man

Thanks to you both, I was able to use both these examples to make a
macro that will find and copy the data I need

Thanks again,
Christopher
 

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