PC Review


Reply
Thread Tools Rate Thread

Compare two columns using loop.

 
 
Peter Gasparik
Guest
Posts: n/a
 
      7th Jun 2010
Hi,

Could you please help my create a loop which will compare each value in
column A one by one with whole column B whether it contain value in column B
and if yes the it picks up value from column C and put it to column D.

Please see example.

Please note the search must be able to find value which is included in
string of the text like Peter must be finding in PeterIsGood.

Example:
A B C D
Peter PeterIsGood T1 T1
Martin Test T2 N/A
John Cool T3 N/A
Oscar PeterIsGood T4 T1
Tom Tomknowall T5 T5
Joseph Summer T6 N/A

Many thanks,

Peter.
 
Reply With Quote
 
 
 
 
Otto Moehrbach
Guest
Posts: n/a
 
      7th Jun 2010
Something like this perhaps. I assumed your headers are in row 1 and your
data starts in row 2. HTH Otto
Sub CompareCol()
Dim rColA As Range, rColB As Range, i As Range
Set rColA = Range("A2", Range("A" & Rows.Count).End(xlUp))
Set rColB = Range("B2", Range("B" & Rows.Count).End(xlUp))
For Each i In rColA
If Not rColB.Find(What:=i.Value) Is Nothing Then
i.Offset(, 3) = i.Offset(, 2)
End If
Next i
End Sub

"Peter Gasparik" <(E-Mail Removed)> wrote in message
news:8C26CCAA-6C50-4AEF-84CE-(E-Mail Removed)...
> Hi,
>
> Could you please help my create a loop which will compare each value in
> column A one by one with whole column B whether it contain value in column
> B
> and if yes the it picks up value from column C and put it to column D.
>
> Please see example.
>
> Please note the search must be able to find value which is included in
> string of the text like Peter must be finding in PeterIsGood.
>
> Example:
> A B C D
> Peter PeterIsGood T1 T1
> Martin Test T2 N/A
> John Cool T3 N/A
> Oscar PeterIsGood T4 T1
> Tom Tomknowall T5 T5
> Joseph Summer T6 N/A
>
> Many thanks,
>
> Peter.


 
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
Loop, Compare, Match & Total Paul Black Microsoft Excel Programming 1 28th Jul 2007 12:14 PM
Loop Down Columns and Compare Values DrwRob28 Microsoft Excel Programming 5 15th Aug 2006 06:21 PM
Loop to compare and delete or leave Lee Jeffery Microsoft Excel New Users 4 28th Jul 2004 05:12 AM
Loop,Compare,Write Michael168 Microsoft Excel Programming 1 25th May 2004 06:41 PM
Re: Loop and Compare JWolf Microsoft Excel Programming 2 12th May 2004 04:01 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:40 PM.