Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Matching Columns

Hi All,

I have 6 Column with multiple rows data in excel sheet. The example is given
below:

A B C D E F
x 1 x x x x
x x x x x x
x x x 1 x 2

I want to compare Column B value with Column D value. If this match, then
copy the value given in Column F into column G and in Column H show the Row
Number from which the value is copied from.

Results needed:

A B C D E F G H
x 1 x x x x 2 R3
x x x x x x x x
x x x 1 x 2 x x

Thanks in advance.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,071
Default Matching Columns

Try this. I assumed row 1 has headers and your data starts in row 2.
Change this as needed. HTH Otto
Sub DoIt()
Dim rColB As Range, rColD As Range
Dim i As Range, FoundCell As Range
Set rColB = Range("B2", Range("B" & Rows.Count).End(xlUp))
Set rColD = Range("D2", Range("D" & Rows.Count).End(xlUp))
For Each i In rColB
If Not rColD.Find(What:=i, LookAt:=xlWhole) Is Nothing Then
Set FoundCell = rColD.Find(What:=i, LookAt:=xlWhole)
i.Offset(, 5) = FoundCell.Offset(, 2)
i.Offset(, 6) = "R" & FoundCell.Row
End If
Next i
End Sub

"ng6971" wrote in message
...
Hi All,

I have 6 Column with multiple rows data in excel sheet. The example is
given
below:

A B C D E F
x 1 x x x x
x x x x x x
x x x 1 x 2

I want to compare Column B value with Column D value. If this match, then
copy the value given in Column F into column G and in Column H show the
Row
Number from which the value is copied from.

Results needed:

A B C D E F G H
x 1 x x x x 2 R3
x x x x x x x x
x x x 1 x 2 x x

Thanks in advance.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Matching Columns

Thank you very much. Works perfect.



"Otto Moehrbach" wrote:

Try this. I assumed row 1 has headers and your data starts in row 2.
Change this as needed. HTH Otto
Sub DoIt()
Dim rColB As Range, rColD As Range
Dim i As Range, FoundCell As Range
Set rColB = Range("B2", Range("B" & Rows.Count).End(xlUp))
Set rColD = Range("D2", Range("D" & Rows.Count).End(xlUp))
For Each i In rColB
If Not rColD.Find(What:=i, LookAt:=xlWhole) Is Nothing Then
Set FoundCell = rColD.Find(What:=i, LookAt:=xlWhole)
i.Offset(, 5) = FoundCell.Offset(, 2)
i.Offset(, 6) = "R" & FoundCell.Row
End If
Next i
End Sub

"ng6971" wrote in message
...
Hi All,

I have 6 Column with multiple rows data in excel sheet. The example is
given
below:

A B C D E F
x 1 x x x x
x x x x x x
x x x 1 x 2

I want to compare Column B value with Column D value. If this match, then
copy the value given in Column F into column G and in Column H show the
Row
Number from which the value is copied from.

Results needed:

A B C D E F G H
x 1 x x x x 2 R3
x x x x x x x x
x x x 1 x 2 x x

Thanks in advance.


.

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
Matching 2 columns Vic Excel Discussion (Misc queries) 9 April 29th 09 11:46 PM
Matching Columns Leo Setting up and Configuration of Excel 2 April 3rd 08 05:44 PM
matching on columns nick Excel Discussion (Misc queries) 0 October 24th 06 05:02 PM
I need help matching columns [email protected] Excel Programming 0 August 4th 06 05:53 PM
matching 2 columns ann Excel Programming 1 April 19th 05 12:16 AM


All times are GMT +1. The time now is 07:39 AM.

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"