Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Junior Member
 
Posts: 2
Unhappy Identifying common data between 2 cells

Hello- I am trying to identify common criteria between 2 cells using Excel 2007. For instance: I have a series of numbers and sometimes letters in 1 cell (manufactures part number). I want to compare to another cell that has similar but not exactly the same data.
The info might look like this....(Cell 1) 55758 vs. (Cell 2) AVT55758.
Another example could be (Cell 1) abc55758 vs. (cell 2) AVT55758950. In both examples, the consective series of numbers "55758" are common, therefore this would be a valid match.
The difference is between how a vendor might list a product. In reality, it's the same product. I want to be able to either have a macro or a formula that could match a minimum of 4 consecutive numbers and give me a result that says it's a good match. If it's 5 cons. numbers, then it's an excellent match. It's a time eating process to manually view data and a macro or formula like this would be a great time saver. Thanks.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Identifying common data between 2 cells

On Wednesday, November 21, 2012 5:53:24 AM UTC+10, MRPRMR wrote:
Hello- I am trying to identify common criteria between 2 cells using

Excel 2007. For instance: I have a series of numbers and sometimes

letters in 1 cell (manufactures part number). I want to compare to

another cell that has similar but not exactly the same data.

The info might look like this....(Cell 1) 55758 vs. (Cell 2) AVT55758.



Another example could be (Cell 1) abc55758 vs. (cell 2) AVT55758950. In

both examples, the consective series of numbers "55758" are common,

therefore this would be a valid match.

The difference is between how a vendor might list a product. In

reality, it's the same product. I want to be able to either have a macro

or a formula that could match a minimum of 4 consecutive numbers and

give me a result that says it's a good match. If it's 5 cons. numbers,

then it's an excellent match. It's a time eating process to manually

view data and a macro or formula like this would be a great time saver.

Thanks.









--

MRPRMR


Give this a try:

Public Function MATCH_STRENGTH(InputValue As String, CompareValue As String) As Integer

Dim InputStringLength As Integer
Dim i As Integer
Dim MatchValue As String

InputStringLength = Len(InputValue)

' Look for 5 match
For i = 1 To InputStringLength - 5
MatchValue = Mid(InputValue, i, 5)
If InStr(CompareValue, MatchValue) 0 Then
MATCH_STRENGTH = 5
Exit Function
End If
Next i

' Look for 4 match
For i = 1 To InputStringLength - 4
MatchValue = Mid(InputValue, i, 4)
If InStr(CompareValue, MatchValue) 0 Then
MATCH_STRENGTH = 4
Exit Function
End If
Next i

MATCH_STRENGTH = 0


End Function


You should then be able to call it in Excel like:

=MATCH_STRENGTH(A1,B1)
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
Identifying common data between 2 cells MRPRMR Excel Worksheet Functions 1 November 17th 12 08:48 AM
Identifying the # of cells containing data WA Excel Worksheet Functions 2 March 17th 09 04:17 PM
Identifying coloured cells KI Excel Discussion (Misc queries) 3 April 10th 08 02:33 PM
Identifying empty cells in VBA David Excel Programming 3 December 7th 05 07:12 PM
Identifying #N/A cells Lee Harris Excel Worksheet Functions 1 November 18th 05 02:57 AM


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

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

About Us

"It's about Microsoft Excel"