Matching and then moving Data

care123

New Member
Joined
Mar 26, 2013
Messages
16
Hi,

I wonder if anyone would be able to help with with the below

I have some spread sheets, the first contains all our customers and their contact details "name" "email" and "phone", the others are split into specific contracts and contain "name" (and other data)

What i want to do is somehow match and move the details from the 1st to the others. So check if the "name" appears in both sheets and if so copy the associated "email" and "Phone" data from the contact details to the specific contract spreadsheet. I hope that makes sense, please ask if not.

As there are over 1500 records this will be a long task to do by hand, so any advise would be really great.

I know using vlookup will show me matches but am at a loss on how to expand on this

Thank you for your time

Regards

Very sorry if I have not explained well, please just ask and I will clarify
 
care123,

From reading your original request/instructions it sounded like there were more/different contract worksheets.

I had asked for:

2. At least two of the other worksheets with all their correct titles in the correct locations, and, at least the "name" column complete similar to the original worksheet (above), and, with their correct worksheet names.

Please supply another workbook/worksheet, containing another of the contract worksheets.
 
Upvote 0

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
care123,

Checking on the data structure of the two worksheets seen so far.

Are the following two screenshots correct based on worksheet names, cells, rows, columns locations?


Excel 2007
ABCDEFGH
1
2
3First NameSurnamePhoneEmail
4AlanSmith111 222 33a@hotmail.com
5AlanWhite222 111 33w@hotmail.com
6johnSmith123455j@hotmail.com
7AliWhite12-2067851aw@gmail.com
8marcblue08-65342mb@yahoo.com
9
maincontact



Excel 2007
ABCDEFGHIJKL
1SURNAMENAMEPhoneEmailNATIONALITYSERVICE USEDCOMPANY NAMESTART VISAEND OF VISANEAR EXPIREREMARK
2AlanWhiteIND11/04/15N
3AliWhiteCAN30/06/14X
4
BUSINESS VISA
 
Upvote 0
Hi,
. I am not sure if you want a formula or a VBA program.? But I am a beginner practicing with VBA sorting Programs. I wrote a program for you to be going on with. See how you get on with it and if it is in the direction of what you want. It is very simple, inflexible and assumes for example your data headings are always in the same order. Once we know exactly wot you want, that is to say how your data in the practice could look like (Heading order, maximum number of data Rows (records) , etc. we can do something better!
. I put the macro in the first sheet (“BUSINESS VISA”) Module of the file I return to you Here:
FileSnack | Easy file sharing

. If you do want a VBA program but are not sure how to run it, then get back and we will explain further. The Code name is care123SimplistSortOFSort.

Here is the code :

<font face=Calibri><SPAN style="color:#00007F">Option</SPAN> <SPAN style="color:#00007F">Explicit</SPAN> <SPAN style="color:#007F00">' Not necerssary but good idea to help find mistakes- forces you to define variable types</SPAN><br><SPAN style="color:#00007F">Sub</SPAN> care123SimplistSortOFSort()<br><SPAN style="color:#00007F">Dim</SPAN> wkstdata <SPAN style="color:#00007F">As</SPAN> Worksheet, wkstFinal <SPAN style="color:#00007F">As</SPAN> Worksheet, Rngdta <SPAN style="color:#00007F">As</SPAN> Range <SPAN style="color:#007F00">'give Methods and Properties of the Objects</SPAN><br><SPAN style="color:#00007F">Set</SPAN> wkstFinal = ThisWorkbook.Worksheets("BUSINESS VISA") <SPAN style="color:#007F00">' Set the specific Worksheet</SPAN><br>Set wkstdata = Workbooks("datasheet").Sheets("maincontact") <SPAN style="color:#007F00">' Set the specific Worksheet</SPAN><br>Set Rngdta = wkstdata.UsedRange <SPAN style="color:#007F00">' Set the specific Range (UsedRange Property finds wher it is</SPAN><br><SPAN style="color:#00007F">Dim</SPAN> dtRw <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Byte</SPAN>, dtCm <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Byte</SPAN>, BVRw <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Byte</SPAN>, BVCm <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Byte</SPAN> <SPAN style="color:#007F00">' limit rows and columns for now to 255</SPAN><br><SPAN style="color:#00007F">Dim</SPAN> dtstRw <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Byte</SPAN>, dtstCm <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Byte</SPAN>, dtEdRw <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Byte</SPAN>, dtEdCm <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Byte</SPAN>, BVedRw <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Byte</SPAN> <SPAN style="color:#007F00">'limit rows and columns for now to 255</SPAN><br><SPAN style="color:#00007F">Let</SPAN> dtstRw = Rngdta.Cells(1, 1).Row + 1<br><SPAN style="color:#00007F">Let</SPAN> BVedRw = wkstFinal.Cells(Rows.Count, 1).End(xlUp).Row<br><SPAN style="color:#00007F">Let</SPAN> dtstCm = Rngdta.Cells(1, 1).Column<br><SPAN style="color:#00007F">Let</SPAN> dtEdRw = wkstdata.Cells(Rows.Count, dtstCm).End(xlUp).Row<br>  <SPAN style="color:#00007F">For</SPAN> BVRw = 2 <SPAN style="color:#00007F">To</SPAN> BVedRw <SPAN style="color:#007F00">' take each row in final Table</SPAN><br>    <SPAN style="color:#00007F">For</SPAN> dtRw = dtstRw <SPAN style="color:#00007F">To</SPAN> dtEdRw <SPAN style="color:#00007F">Step</SPAN> 1 <SPAN style="color:#007F00">' then go through every row in data</SPAN><br>    <SPAN style="color:#00007F">If</SPAN> wkstFinal.Cells(BVRw, 1).Value = wkstdata.Cells(dtRw, dtstCm).Value And wkstFinal.Cells(BVRw, 2).Value = wkstdata.Cells(dtRw, dtstCm + 1).Value <SPAN style="color:#00007F">Then</SPAN> <SPAN style="color:#007F00">' Check for name match, then if found..</SPAN><br>    wkstFinal.Cells(BVRw, 3).Value = wkstdata.Cells(dtRw, dtstCm + 2).Value <SPAN style="color:#007F00">'write phone number in</SPAN><br>    wkstdata.Cells(dtRw, dtstCm + 3).Copy Destination:=wkstFinal.Cells(BVRw, 4) <SPAN style="color:#007F00">'Copy Email (Hyperlink) in</SPAN><br>    <SPAN style="color:#00007F">Else</SPAN> <SPAN style="color:#007F00">'otherwise</SPAN><br>    <SPAN style="color:#007F00">'Do nothing</SPAN><br>    <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">If</SPAN><br>    <SPAN style="color:#00007F">Next</SPAN> dtRw <SPAN style="color:#007F00">' look at next data Row</SPAN><br>  <SPAN style="color:#00007F">Next</SPAN> BVRw <SPAN style="color:#007F00">' Move on to next final table Roe and go through the data rows again</SPAN><br><SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN> <SPAN style="color:#007F00">'care123SimplistSortOFSort()</SPAN></FONT>


It turns this:


Book1
ABCDEFGHIJK
1SURNAMENAMEPhoneEmailNATIONALITYSERVICE USEDCOMPANY NAMESTART VISAEND OF VISANEAR EXPIREREMARK
2AlanWhite11.04.15N
3AliWhite30.06.14X
BUSINESS VISA



Into this:


Book1
ABCDEFGHIJK
1SURNAMENAMEPhoneEmailNATIONALITYSERVICE USEDCOMPANY NAMESTART VISAEND OF VISANEAR EXPIREREMARK
2AlanWhite222 111 33w@hotmail.com11.04.15N
3AliWhite12-2067851aw@gmail.com30.06.14X
BUSINESS VISA



Alan.

Note:
. Your data file must be open and named as the one you sent. (that could be changed to be any file you have opened)
. Your data can go anywhere in the data sheet, but must have the headings in the order you gave –( that is one of the improvements that could be made, for example to allow for your headings coming in any order). In fact I am learning that you can just about do anything with VBA!! (Once you know how!!).
. Your names must be spelt correctly
. For now the program is limited to 255 Rows.

Alan.
 
Upvote 0
P.s. I seem to have accidentally erased the nationality.. You can easilly type that back in, or presumably you will test with real name/ nationallity data in the final Table anyway!
Alan
 
Upvote 0
care123,

Checking on the data structure of the two worksheets seen so far.

Are the following two screenshots correct based on worksheet names, cells, rows, columns locations?

Excel 2007
ABCDEFGH
1
2
3First NameSurnamePhoneEmail
4AlanSmith111 222 33a@hotmail.com
5AlanWhite222 111 33w@hotmail.com
6johnSmith123455j@hotmail.com
7AliWhite12-2067851aw@gmail.com
8marcblue08-65342mb@yahoo.com
9

<colgroup><col style="width: 25pxpx"><col><col><col><col><col><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>
maincontact



Excel 2007
ABCDEFGHIJKL
1SURNAMENAMEPhoneEmailNATIONALITYSERVICE
USED
COMPANY
NAME
START
VISA
END OF
VISA
NEAR
EXPIRE
REMARK
2AlanWhiteIND11/04/15N
3AliWhiteCAN30/06/14X
4

<colgroup><col style="width: 25pxpx"><col><col><col><col><col><col><col><col><col><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>
BUSINESS VISA

Hi,

Yes they are
 
Upvote 0
care123,

From reading your original request/instructions it sounded like there were more/different contract worksheets.

I had asked for:

2. At least two of the other worksheets with all their correct titles in the correct locations, and, at least the "name" column complete similar to the original worksheet (above), and, with their correct worksheet names.

Please supply another workbook/worksheet, containing another of the contract worksheets.


Please supply another workbook/worksheet, containing another of the contract worksheets
 
Upvote 0

Forum statistics

Threads
1,217,047
Messages
6,134,282
Members
449,863
Latest member
Snowmanx812

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