Home |
Search |
Today's Posts |
#1
![]() |
|||
|
|||
![]()
Hello,
Anybody knows how to find MATCH numbers ? Example : Cell A1 = 1457 Cell A2 = 2467 Return MATCH numbers are 4 and 7. Thank You. |
#2
![]() |
|||
|
|||
![]()
Hi Toyota58,
This UDF will do it: Public Function Matchdigits(string1 As String, string2 As String) As String Dim length As Integer length = WorksheetFunction.Min(Len(string1), Len(string2)) matchdigits = "" For l = 1 To length If Mid(string1, l, 1) = Mid(string2, l, 1) Then Matchdigits = Matchdigits & Mid(string1, l, 1) Next l End Function Put in the cell you want the result in =Matchdigits(A1,A2) Regards, Stefi €˛toyota58€¯ ezt Ć*rta: Hello, Anybody knows how to find MATCH numbers ? Example : Cell A1 = 1457 Cell A2 = 2467 Return MATCH numbers are 4 and 7. Thank You. |
#3
![]() |
|||
|
|||
![]()
Sorry...I'm a newbie. Am I doing the right thing ? I went to TOOLS
MAKRO VB Editor (ALT + F11) Insert module...copy and paste ...all I get is Syntax error... If Mid(string1, l, 1) = Mid(string2, l, 1) Then Matchdigits = Matchdigits & Mid(string1, l, 1) .. |
#4
![]() |
|||
|
|||
![]()
Hi!
If Mid(string1, l, 1) = Mid(string2, l, 1) Then Matchdigits = Matchdigits & Mid(string1, l, 1) This UDF works but the problem is line wrap. The above code needs to be all on one line or use the line continuation character: _ (underscore) If Mid(string1, l, 1) = Mid(string2, l, 1) Then Matchdigits = _ Matchdigits & Mid(string1, l, 1) Biff "toyota58" wrote in message oups.com... Sorry...I'm a newbie. Am I doing the right thing ? I went to TOOLS MAKRO VB Editor (ALT + F11) Insert module...copy and paste ...all I get is Syntax error... If Mid(string1, l, 1) = Mid(string2, l, 1) Then Matchdigits = Matchdigits & Mid(string1, l, 1) . |
#6
![]() |
|||
|
|||
![]()
Very sorry again but ...the formula can only work in a certain way.
Example Cell A1 = 2469 Cell A2 = 1359 Cell A3 = 9 This works OK But it won't work if... Cell A1 = 24569 Cell A2 = 69 Cell A3 = No Return Cell A1 = 134 Cell A2 = 467 Cell A3 = No Return Sorry to trouble you all but it was my mistake not to explain in detail... |
#7
![]() |
|||
|
|||
![]()
Yes, you must be very precise in defining your demands!
This is the function that does what you have defined up to now: Public Function Matchdigits2(string1 As String, string2 As String) As String Dim length As Integer length1 = Len(string1) length2 = Len(string2) Matchdigits2 = "" For l1 = 1 To length1 For l2 = 1 To length2 If Mid(string1, l1, 1) = Mid(string2, l2, 1) Then _ Matchdigits2 = Matchdigits2 & Mid(string1, l1, 1) Next l2 Next l1 End Function You did not give rules for multiple occurence of a digit. This function will put a digit in the result as many times as it occurs. Is that what you want? Regards, Stefi €˛toyota58€¯ ezt Ć*rta: Very sorry again but ...the formula can only work in a certain way. Example Cell A1 = 2469 Cell A2 = 1359 Cell A3 = 9 This works OK But it won't work if... Cell A1 = 24569 Cell A2 = 69 Cell A3 = No Return Cell A1 = 134 Cell A2 = 467 Cell A3 = No Return Sorry to trouble you all but it was my mistake not to explain in detail... |
#8
![]() |
|||
|
|||
![]()
Dear Stefi,
Thank You so much...This is exactly what I want.. |
#9
![]() |
|||
|
|||
![]()
You are welcome! Thanks for the reply!
Stefi €˛toyota58€¯ ezt Ć*rta: Dear Stefi, Thank You so much...This is exactly what I want.. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Find a not exact match using vlookup | Excel Discussion (Misc queries) | |||
find a sum from a list of numbers | Excel Worksheet Functions | |||
Find last match in vllokup | Excel Discussion (Misc queries) | |||
how to build a formula to match numbers in 2 columns with the equ. | Excel Worksheet Functions | |||
Use MATCH to find position of max in 2D range? | Excel Worksheet Functions |