#1   Report Post  
Posted to microsoft.public.excel.worksheet.functions,microsoft.public.excel.programming
external usenet poster
 
Posts: 51
Default Matching !!

Hi,

I have two worksheets - Sheet1 and Sheet2

Sheet 1
Col A Col B
Codes A/C Numbers
Pacific 145762
Atlantic 345782
Monte carlo 478562
Pacific 785


Sheet 2
Col A
Codes ( unique )
Pacific
Atlantic
Monte Carlo

I am using Excel 2007,
I need to match Sheet 2 Col A data with Sheet1 Col A data,
if any match found i need result in Col B of Sheet 2. If there are
more than one then
the A/C numbers to be separated by comma ( eg., 145762,785)

Sheet 1 has Approximately 1.5 Lakh Row

Sheet 2 has only 10,000 rows.

Please help me guys....
  #2   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 857
Default Matching !!

Hi,

You are going to need to write code for this. Also, what is the maximun
number of matches that you could find for 1 code? If it is too many you
won't be able to enter it in a cell.

and now to really show my ignorance - what is Lakh Row?



If this helps, please click the Yes button.

Cheers,
Shane Devenshire


" wrote:

Hi,

I have two worksheets - Sheet1 and Sheet2

Sheet 1
Col A Col B
Codes A/C Numbers
Pacific 145762
Atlantic 345782
Monte carlo 478562
Pacific 785


Sheet 2
Col A
Codes ( unique )
Pacific
Atlantic
Monte Carlo

I am using Excel 2007,
I need to match Sheet 2 Col A data with Sheet1 Col A data,
if any match found i need result in Col B of Sheet 2. If there are
more than one then
the A/C numbers to be separated by comma ( eg., 145762,785)

Sheet 1 has Approximately 1.5 Lakh Row

Sheet 2 has only 10,000 rows.

Please help me guys....

  #3   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 51
Default Matching !!

Hi Shane,

The maximum number of matches for one code would be 3.

Lakh rows is equal 100 thousand rows

Appreciate your time.

Looking for positive response.

Thanks in advance



On Mar 15, 12:06*am, Shane Devenshire
wrote:
Hi,

You are going to need to write code for this. *Also, what is the maximun
number of matches that you could find for 1 code? *If it is too many you
won't be able to enter it in a cell. *

and now to really show my ignorance - what is Lakh Row?

If this helps, please click the Yes button.

Cheers,
Shane Devenshire

" wrote:
Hi,


I have two worksheets - Sheet1 and Sheet2


Sheet 1
Col A * * * * * * *Col B
Codes * * * * * * A/C Numbers
Pacific * * * * * * *145762
Atlantic * * * * * * 345782
Monte carlo * * * 478562
Pacific * * * * * * * 785


Sheet 2
Col A
Codes ( unique )
Pacific
Atlantic
Monte Carlo


I am using Excel 2007,
I need to match Sheet 2 Col A data with Sheet1 Col A data,
if any match found i need result in Col B of Sheet 2. If there are
more than one then
the A/C numbers to be separated by comma ( eg., 145762,785)


Sheet 1 has Approximately 1.5 Lakh Row


Sheet 2 has only 10,000 rows.


Please help me guys....


  #4   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 857
Default Matching !!

Hi,

Here is some code

Adjust your ranges:

Sub Match()
Dim myCon As String
Dim myCell As Range
Dim cell As Range
For Each cell In Sheet2.Range("A2:A10")
myCon = ""
For Each myCell In Sheet1.Range("A1:A15")
If cell = myCell Then
If myCon = "" Then
myCon = myCell.Offset(0, 1)
Else
myCon = myCon & ", " & myCell.Offset(0, 1)
End If
End If
Next myCell
cell.Offset(0, 1) = myCon
Next cell
End Sub

NOTE VBA comparisons are case sensitive, so Monte carlo is not equal to
Monte Carlo

--
If this helps, please click the Yes button.

Cheers,
Shane Devenshire


" wrote:

Hi,

I have two worksheets - Sheet1 and Sheet2

Sheet 1
Col A Col B
Codes A/C Numbers
Pacific 145762
Atlantic 345782
Monte carlo 478562
Pacific 785


Sheet 2
Col A
Codes ( unique )
Pacific
Atlantic
Monte Carlo

I am using Excel 2007,
I need to match Sheet 2 Col A data with Sheet1 Col A data,
if any match found i need result in Col B of Sheet 2. If there are
more than one then
the A/C numbers to be separated by comma ( eg., 145762,785)

Sheet 1 has Approximately 1.5 Lakh Row

Sheet 2 has only 10,000 rows.

Please help me guys....

  #5   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 51
Default Matching !!

Thank u very much,

I created another similar to your code

Sub match()

r1 = Worksheets("sheet1").Cells(Rows.Count, "A").End(xlUp).Row
r2 = Worksheets("sheet2").Cells(Rows.Count, "A").End(xlUp).Row

Set r3 = Worksheets("sheet1")
Worksheets("sheet2").Range("B2").Select
For a = 2 To r2
For i = 2 To r1
If Cells(a, "A") = r3.Cells(i, "A") Then
temp = r3.Cells(i, "B")
te = te & "," & temp
Else
End If
Next i
Cells(a, "B") = te
te = ""
Next a
End Sub

I was testing both codes with short rows say 100, at that time both
runs fast.

When I run on 100 THOUSAND rows, Your code completes in 40 Seconds.
My code completes in 1 Minute 05 Seconds.

Why is it like that any clue ?




On Mar 15, 12:24*am, Shane Devenshire
wrote:
Hi,

Here is some code

Adjust your ranges:

Sub Match()
* * Dim myCon As String
* * Dim myCell As Range
* * Dim cell As Range
* * For Each cell In Sheet2.Range("A2:A10")
* * * * myCon = ""
* * * * For Each myCell In Sheet1.Range("A1:A15")
* * * * * * If cell = myCell Then
* * * * * * * * If myCon = "" Then
* * * * * * * * * * myCon = myCell.Offset(0, 1)
* * * * * * * * Else
* * * * * * * * * * myCon = myCon & ", " & myCell.Offset(0, 1)
* * * * * * * * End If
* * * * * * End If
* * * * Next myCell
* * * * cell.Offset(0, 1) = myCon * *
* * Next cell
End Sub

NOTE VBA comparisons are case sensitive, so Monte carlo is not equal to
Monte Carlo

--
If this helps, please click the Yes button.

Cheers,
Shane Devenshire

" wrote:
Hi,


I have two worksheets - Sheet1 and Sheet2


Sheet 1
Col A * * * * * * *Col B
Codes * * * * * * A/C Numbers
Pacific * * * * * * *145762
Atlantic * * * * * * 345782
Monte carlo * * * 478562
Pacific * * * * * * * 785


Sheet 2
Col A
Codes ( unique )
Pacific
Atlantic
Monte Carlo


I am using Excel 2007,
I need to match Sheet 2 Col A data with Sheet1 Col A data,
if any match found i need result in Col B of Sheet 2. If there are
more than one then
the A/C numbers to be separated by comma ( eg., 145762,785)


Sheet 1 has Approximately 1.5 Lakh Row


Sheet 2 has only 10,000 rows.


Please help me guys....


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 identical data using data only once in the matching proce Robert 1 Excel Discussion (Misc queries) 1 June 29th 07 04:22 PM
Help with Matching Text Fields - Then Moving the Matching Cells Side by Side [email protected] Excel Discussion (Misc queries) 2 June 11th 07 02:38 PM
matching John Excel Worksheet Functions 1 March 29th 07 12:40 PM
Need help matching... Steve Excel Worksheet Functions 0 September 8th 06 12:49 PM
Matching data and linking it to the matching cell yvonne a via OfficeKB.com Links and Linking in Excel 0 July 13th 05 07:30 PM


All times are GMT +1. The time now is 08:47 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"