Hi all:
I have a list of addresses, each with an ID number. I also have
another file that is a list of ID numbers that I have imported from
SPSS. The imported ID numbers contain most but not all of the ID
numbers from the address list.
What I would like to do is to match up the IDs from the imported
file to the address list so that for each case, there would be the
original ID and the imported ID. Where there wasn't an imported ID, it
should be blank in that column.
What I am trying to do is take the ID numbers of subjects who have
responded to a survey and mark them so that I can filter and delete the
addresses of those who did not respond.
Any ideas??????
MarcI'd return the address into a different column (or columns).
If your master data is on Sheet1 and your SPSS data is on Sheet2, you could use
=vlookup() (with the key ID column in column A of each worksheet):
=vlookup(a2,sheet2!a:b,2,false)
or
=if(iserror(vlookup(a2,sheet2!a:b,2,false)),quot;quot;,vlo okup(a2,sheet2!a:b,2,false))
You could expand the range (to Sheet2!a:x) and bring back different columns (2,
3, 4,...) if the addresses are across columns.
You may want to read Debra Dalgleish's notes:
www.contextures.com/xlFunctions02.html (for =vlookup())
and
www.contextures.com/xlFunctions03.html (for =index(match()))
mcap wrote:
gt;
gt; Hi all:
gt;
gt; I have a list of addresses, each with an ID number. I also have
gt; another file that is a list of ID numbers that I have imported from
gt; SPSS. The imported ID numbers contain most but not all of the ID
gt; numbers from the address list.
gt;
gt; What I would like to do is to match up the IDs from the imported
gt; file to the address list so that for each case, there would be the
gt; original ID and the imported ID. Where there wasn't an imported ID, it
gt; should be blank in that column.
gt;
gt; What I am trying to do is take the ID numbers of subjects who have
gt; responded to a survey and mark them so that I can filter and delete the
gt; addresses of those who did not respond.
gt;
gt; Any ideas??????
gt;
gt; Marc
--
Dave Peterson
This one I made up for similar purposes many years ago, means you have
to really tweak it to your needs. Assumes you have the two lists in the
same workbook and there are no empty cells util the end of the list.
So wherever there is an gt;gt;gt;gt;UPDATE indicated you have to change the
code as per your workbook.
Sub Vergleich()
Dim ToList, FromList
Dim Friss, RefData
Dim RefTav
Dim StartCell
ToList = quot;Stquot;
' Name of ToList lt;lt;lt;lt;lt;lt;lt;lt;UPDATE rqd. !!!
FromList = quot;Listquot;
' Name of FromList lt;lt;lt;lt;lt;lt;lt;lt;UPDATE rqd.!!!
RefTav = 0
' Offset of the reference data element lt;lt;UPDATE !!!
StartCell = quot;A1quot;
' This is the starting cell on the ToList lt;lt;UPDATE !!!
Sheets(ToList).Select
Range(StartCell).Select
Sheets(FromList).Select
Range(quot;A1quot;).Select
' Starting Cell at FromList lt;lt;lt;lt;lt;lt;lt;lt;UPDATE !!!
For cik01 = 1 To 20000
ActiveCell.Offset(1, 0).Select
If ActiveCell.Offset(0, RefTav) = Empty Then GoTo 1000
'If ref. data is empty, quit
Friss = ActiveCell
RefData = ActiveCell.Offset(0, RefTav)
Sheets(ToList).Select
Range(StartCell).Select 'lt;lt;lt;lt;lt;lt;lt;lt;lt;lt; UPDATE RQD.
For cik02 = 1 To 2000
ActiveCell.Offset(1, 0).Select
If ActiveCell.Offset(0, RefTav) = RefData Then
ActiveCell.Formula = Friss
ActiveCell.Offset(0, 12).FormulaR1C1 = quot;matchedquot;
'lt;lt;lt;lt;UPDATE
Range(StartCell).Select
Sheets(FromList).Select
ActiveCell.Offset(0, 12).FormulaR1C1 = quot;matchedquot;
'lt;lt;lt;lt;UPDATE
GoTo 100
ElseIf ActiveCell.Offset(0, RefTav) = Empty Then
Range(StartCell).Select
Sheets(FromList).Select
ActiveCell.Offset(0, 12).FormulaR1C1 = _
quot;not foundquot;
'lt;lt;lt;lt;UPDATE
GoTo 100
Else
End If
Next cik02
100 Next cik01
1000 Beep
End SubCheers, Gabor--
Gabor
------------------------------------------------------------------------
Gabor's Profile: www.excelforum.com/member.php...foamp;userid=6179
View this thread: www.excelforum.com/showthread...hreadid=531253Wow...thanks!!! Seems complicated as I am a total excel novice. SPSS
seems a lot easier for things this but I am working with mail merging
and other things that I prefer to use excel with. I will have a crack
at it. Thanks again!!!!!!!!
Marc
- Sep 23 Tue 2008 20:46
merging two files
close
全站熱搜
留言列表
發表留言