PC Review


Reply
Thread Tools Rate Thread

Comparing Values In 2 Columns

 
 
hilaryj@st-albans.suffolk.sch.uk
Guest
Posts: n/a
 
      8th Feb 2007
Hi, i have 2 list of students names both of which are not up to date
with each other and because of this one list has more students than
the other. I want to search for students names and see if there is a
match, if a match is found i need to copy the email address and paste
it into the cell by the other name in the other list. See Below

My spreadsheet has columns titled, (A)Display Name, (B)Display Email,
(C)Sims Name and (D)Sims Email. I basically want to write a script
that takes each individual display name in column A and searches in
column C for an identical match, if a match is found i then need it to
look at column D and if an email address is present copy it into
column B on the row that the display name is on? Is there a quick
method?

Thanks In Advance

Jay

 
Reply With Quote
 
 
 
 
Don Guillett
Guest
Posts: n/a
 
      8th Feb 2007
Have a look in the vba help index for FINDNEXT. There is a good example.

--
Don Guillett
SalesAid Software
(E-Mail Removed)
<(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi, i have 2 list of students names both of which are not up to date
> with each other and because of this one list has more students than
> the other. I want to search for students names and see if there is a
> match, if a match is found i need to copy the email address and paste
> it into the cell by the other name in the other list. See Below
>
> My spreadsheet has columns titled, (A)Display Name, (B)Display Email,
> (C)Sims Name and (D)Sims Email. I basically want to write a script
> that takes each individual display name in column A and searches in
> column C for an identical match, if a match is found i then need it to
> look at column D and if an email address is present copy it into
> column B on the row that the display name is on? Is there a quick
> method?
>
> Thanks In Advance
>
> Jay
>



 
Reply With Quote
 
Earl Kiosterud
Guest
Posts: n/a
 
      8th Feb 2007
Jay,

Here's a formula way. Put this in a column (perhaps E), and copy down with the Fill Handle.
=IF(ISERROR(VLOOKUP(A2,$C$2:$D$13,2,FALSE)),"",VLOOKUP(A2,$C$2:$D$13,2,FALSE))

If you want it to return the email address in column B for entries in column A that don't
have a match in column C, use

=IF(ISERROR(VLOOKUP(A2,$C$2:$D$13,2,FALSE)),B2,VLOOKUP(A2,$C$2:$D$13,2,FALSE))

If there are already some email addresses in column B, then this will have to be combined
with column B with another formula.

You asked for a script. Here's a macro. It will overlay any email in B if it finds a match
in D

Sub CombineLists2()
Dim ARow As Long
Dim CRow As Long
Dim CellA As Range, ColA As Range
Dim CellC As Range, ColC As Range
ARow = 2 ' starting row
CRow = 2
Set ColA = Range(Cells(ARow, 1), Cells(ARow, 1).End(xlDown))
Set ColC = Range(Cells(CRow, 3), Cells(CRow, 3).End(xlDown))
For Each CellA In ColA
CRow = 2
For Each CellC In ColC
If CellA = CellC Then ' match name?
CellA.Offset(0, 1) = CellC.Offset(0, 1) ' put email address in B
End If
Next CellC
Next CellA
End Sub

--
Earl Kiosterud
www.smokeylake.com
-----------------------------------------------------------------------
<(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi, i have 2 list of students names both of which are not up to date
> with each other and because of this one list has more students than
> the other. I want to search for students names and see if there is a
> match, if a match is found i need to copy the email address and paste
> it into the cell by the other name in the other list. See Below
>
> My spreadsheet has columns titled, (A)Display Name, (B)Display Email,
> (C)Sims Name and (D)Sims Email. I basically want to write a script
> that takes each individual display name in column A and searches in
> column C for an identical match, if a match is found i then need it to
> look at column D and if an email address is present copy it into
> column B on the row that the display name is on? Is there a quick
> method?
>
> Thanks In Advance
>
> Jay
>



 
Reply With Quote
 
hilaryj@st-albans.suffolk.sch.uk
Guest
Posts: n/a
 
      8th Feb 2007
On 8 Feb, 15:32, "Earl Kiosterud" <some...@nowhere.com> wrote:
> Jay,
>
> Here's a formula way. Put this in a column (perhaps E), and copy down with the Fill Handle.
> =IF(ISERROR(VLOOKUP(A2,$C$2:$D$13,2,FALSE)),"",VLOOKUP(A2,$C$2:$D$13,2,FALS*E))
>
> If you want it to return the email address in column B for entries in column A that don't
> have a match in column C, use
>
> =IF(ISERROR(VLOOKUP(A2,$C$2:$D$13,2,FALSE)),B2,VLOOKUP(A2,$C$2:$D$13,2,FALS*E))
>
> If there are already some email addresses in column B, then this will have to be combined
> with column B with another formula.
>
> You asked for a script. Here's a macro. It will overlay any email in B if it finds a match
> in D
>
> Sub CombineLists2()
> Dim ARow As Long
> Dim CRow As Long
> Dim CellA As Range, ColA As Range
> Dim CellC As Range, ColC As Range
> ARow = 2 ' starting row
> CRow = 2
> Set ColA = Range(Cells(ARow, 1), Cells(ARow, 1).End(xlDown))
> Set ColC = Range(Cells(CRow, 3), Cells(CRow, 3).End(xlDown))
> For Each CellA In ColA
> CRow = 2
> For Each CellC In ColC
> If CellA = CellC Then ' match name?
> CellA.Offset(0, 1) = CellC.Offset(0, 1) ' put email address in B
> End If
> Next CellC
> Next CellA
> End Sub
>
> --
> Earl Kiosterudwww.smokeylake.com
> -----------------------------------------------------------------------<hila...@st-albans.suffolk.sch.uk> wrote in message
>
> news:(E-Mail Removed)...
>
>
>
> > Hi, i have 2 list of students names both of which are not up to date
> > with each other and because of this one list has more students than
> > the other. I want to search for students names and see if there is a
> > match, if a match is found i need to copy the email address and paste
> > it into the cell by the other name in the other list. See Below

>
> > My spreadsheet has columns titled, (A)Display Name, (B)Display Email,
> > (C)Sims Name and (D)Sims Email. I basically want to write a script
> > that takes each individual display name in column A and searches in
> > column C for an identical match, if a match is found i then need it to
> > look at column D and if an email address is present copy it into
> > column B on the row that the display name is on? Is there a quick
> > method?

>
> > Thanks In Advance

>
> > Jay- Hide quoted text -

>
> - Show quoted text -


Cheers Earl,

Worked a treat thanks very much

Jay

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Comparing values in two columns =?Utf-8?B?UC5oYW1zYQ==?= Microsoft Excel Misc 4 13th May 2007 04:50 PM
Comparing values in columns Sandy Microsoft Excel Worksheet Functions 2 19th Apr 2007 09:40 AM
Comparing Values in 2 Columns esta.monn@gmail.com Microsoft Excel Misc 2 31st Oct 2006 10:41 PM
Comparing values in two columns and displaying missing values in n =?Utf-8?B?Y3BldHRh?= Microsoft Excel Programming 1 2nd Apr 2005 06:18 AM
Comparing values in two columns nicoll Microsoft Excel Programming 3 11th Apr 2004 03:17 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:16 AM.