Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default copmapre and rank cells

Howdy,

I would like to compare cells that I know are not exact matches. If the
cells have more than 3,4,5,x characters different I want to return a value
basically telling me how close of a match I have.

Any ideas?

thanks,
Mike


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 102
Default copmapre and rank cells

Hi Mike,

You could try something like what I have below, however it doesn't deal with
multiple instances of strings within strings.

'The function "Compare" returns zero if Second value doesn't exist in First
value
'or if both values are equal
'Otherwise "Compare" returns the difference between the two strings lengths
'Test by sticking values in Range("A1") and Range("A2") on any worksheet

Function Compare(Rng1, Rng2) As Integer
Dim First As Variant, Second As Variant
If Len(Rng1) = Len(Rng2) Then
First = Rng1
Second = Rng2
Else
First = Rng2
Second = Rng1
End If

If InStr(First, Second) 0 Then
Compare = Len(First) - Len(Second)
Else
Compare = 0
End If
End Function

Sub TestIt()
MsgBox Compare(Range("A1").Value, Range("A2").Value)
End Sub

Hope this helps,
Regards, Rocky McKinley
"MikeD" wrote in message
news:SHb1b.219066$YN5.149586@sccrnsc01...
Howdy,

I would like to compare cells that I know are not exact matches. If the
cells have more than 3,4,5,x characters different I want to return a value
basically telling me how close of a match I have.

Any ideas?

thanks,
Mike




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default compare and rank cells

I'll give that a try. thanks

and I have no idea where 'copmapre' came from. Must have slipped by the
spell checker.



"Rocky McKinley" wrote in message
...
Hi Mike,

You could try something like what I have below, however it doesn't deal

with
multiple instances of strings within strings.

'The function "Compare" returns zero if Second value doesn't exist in

First
value
'or if both values are equal
'Otherwise "Compare" returns the difference between the two strings

lengths
'Test by sticking values in Range("A1") and Range("A2") on any worksheet

Function Compare(Rng1, Rng2) As Integer
Dim First As Variant, Second As Variant
If Len(Rng1) = Len(Rng2) Then
First = Rng1
Second = Rng2
Else
First = Rng2
Second = Rng1
End If

If InStr(First, Second) 0 Then
Compare = Len(First) - Len(Second)
Else
Compare = 0
End If
End Function

Sub TestIt()
MsgBox Compare(Range("A1").Value, Range("A2").Value)
End Sub

Hope this helps,
Regards, Rocky McKinley
"MikeD" wrote in message
news:SHb1b.219066$YN5.149586@sccrnsc01...
Howdy,

I would like to compare cells that I know are not exact matches. If the
cells have more than 3,4,5,x characters different I want to return a

value
basically telling me how close of a match I have.

Any ideas?

thanks,
Mike






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
rank the numbers / range of data using 'RANK' and 'ABS' KP Excel Worksheet Functions 1 March 8th 08 05:50 PM
Rank a column but not include some cells Pillar Excel Discussion (Misc queries) 10 October 8th 06 05:33 AM
RANK, duplicate ranking but no gaps in rank arron laing Excel Worksheet Functions 4 June 14th 06 07:57 AM
Rank items, select one start date, have remaining dates follow based on rank rob normerica Excel Discussion (Misc queries) 1 August 15th 05 09:36 PM
Can I assign a rank based on a cells' value Jason Excel Worksheet Functions 1 March 10th 05 09:54 PM


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