Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Compare two columns using loop.

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.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,071
Default Compare two columns using loop.

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" wrote in message
...
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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
compare cells, copy, loop Immortal_Creations Excel Worksheet Functions 2 July 17th 09 03:34 PM
Loop, Compare, Match & Total Paul Black Excel Programming 1 July 28th 07 12:14 PM
Loop Down Columns and Compare Values DrwRob28 Excel Programming 5 August 15th 06 06:21 PM
Loop,Compare,Write Michael168[_75_] Excel Programming 1 May 25th 04 06:41 PM
Loop and Compare JWolf Excel Programming 2 May 12th 04 04:01 PM


All times are GMT +1. The time now is 06:13 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"