ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   how do i compare 2 cells and extract the text that is different? (https://www.excelbanter.com/excel-programming/342086-how-do-i-compare-2-cells-extract-text-different.html)

ky1234

how do i compare 2 cells and extract the text that is different?
 
I have 2 columns that contain text that is different, but almost matches
except for 1 character that does not. i want to find out what is the
character in the cell that does NOT match.
ie.
column a = APTK745 (i want to return the P)
column b = ARTK745 (i want to return the R)
or
column a = ANPF841 (i want to return the F)
column b = ANPE841 (i want to return the E)


Datasort

how do i compare 2 cells and extract the text that is different?
 
I have a solution if the changed characters are in the same place or you are
looking for the first character that is changed in a cell.


Function FindDif (strFirst as string, strSecond as string) as string


Dim iLoopChar as integer, bFoundDif as boolean

For iLoopChar = 1 to len(strFirst)
If mid (strFirst,iloopchar,1) < mid (strSecond,iloopchar,1) then
bFoundDif = true
Exit for
End if
Next iLoopChar

If bFoundDif then

FindDif = mid (strFirst,iloopchar,1)

Else
FindDif = €œN/A€

End if


exit Funciton


Good luck

--
Stewart Rogers
DataSort Software, L.C.


"ky1234" wrote:

I have 2 columns that contain text that is different, but almost matches
except for 1 character that does not. i want to find out what is the
character in the cell that does NOT match.
ie.
column a = APTK745 (i want to return the P)
column b = ARTK745 (i want to return the R)
or
column a = ANPF841 (i want to return the F)
column b = ANPE841 (i want to return the E)



All times are GMT +1. The time now is 10:32 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com