Matching fields in worksheet

K

Kevin

I have one worksheet with a set up data and wnother
worksheet with more data. Both sheets have a match
between them (ID). How would I combine the two
worksheets into one that would have all the data combines
for that one common match (ID)? Is this a match to???
 
A

Amanda

Kevin,
You are going to need to create macro in vba to perform
this task.
I am not sure how your data is set up. For example do you
have columns A:D on worksheet(1) with different data that
is on A:D in worksheet(2).
I assume the common identifier would be ColumnA.

Regarless create a loop

'here is the code, or at least the concept. You can cut
and paste this, but you must change the ranges and the
sheet index or instead of using sheet indexes you can use
this type of statement:

Application.Worksheets("YoursheetNamehere").range
("Rangehere").value


Sub FillSheet3()

Dim UniqueID as variant

for i=1 to lastrow of data in worksheet(1)
UniqueID = Application.sheet(1).range("A"& i).value
for j = 1 to lastrowof data in worksheet(2)

if UniqueID = Application.sheet(1).range("A"&
j).value


'then you have found what you are looking for, and
stick all the data in row j and i into sheet(3)
'I assume you want to stick the unique ID of both
sheets in column A, if not change to what you need it to
be



Application.sheet(3).range("A" & i ).value = UniqueID


'fill in the appropriate cells using this type of process
'You will want to put the data from sheet 1 and 2 into
sheet 3. you must decided what column of data goes to what
column

Application.sheet(3).range("B" & i).value =
Application.Sheet().range("" & i).value

end if
next j
next i


end sub

Once you have finished the macro, go to Tools->Macro->Run,
and select the macro you have just created to run it.

It was hard for me to completely determine your situation,
so I hope this helps. Let me know if you need any other
assitance.
 

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