Your example seems to imply some assumptions. Is the value in column 2 ALWAYS longer than the value in column 1? What if the values are: ABC1alpha and ABC1beta what do you want in the third column? When you said that you want to "extract the characters", does that mean that you want the first character that is different in both columns? (ab) or do you want ALL characters that are different in both columns? (alphabeta) since I don't know the answer to these questions, I'll simply start with this: I would recommend a function: Option Explicit Public Function Compare_Strings(sVal1, sVal2) Dim nLen As Integer, nPos As Integer Dim bFlag As Boolean bFlag = False nLen = Len(sVal1) If (Len(sVal2) < nLen) Then nLen = Len(sVal2) For nPos = 1 To nLen If (Mid(UCase(sVal1), nPos, 1) <> Mid(UCase(sVal2), nPos, 1)) Then bFlag = True Exit For End If Next If (bFlag) Then Compare_Strings = Mid(UCase(sVal1), nPos, 1) & ", " & Mid(UCase(sVal2), nPos, 1) Else If (Len(sVal1) <> Len(sVal2)) Then If (Len(sVal1) > Len(sVal2)) Then Compare_Strings = Mid(UCase(sVal1), nPos, 1) Else Compare_Strings = Mid(UCase(sVal2), nPos, 1) End If Else Compare_Strings = "match" End If End If End Function Then, in your third column, use: =Compare_Strings(A1,B1) Paul On Saturday, October 27, 2012 1:22:01 AM UTC-4, saravanan R wrote:
> Hi xlts, > > I need your help on is there any macro /function to compare 2 adjacent > columns(cells) and extract the characters which makes difference in the > next column > > Coloumn1. Column2. (required o/p) > Abc1 Abc1x X > > Thanks & regards, > Saravanan R -- Join official facebook page of this forum @ https://www.facebook.com/discussexcel FORUM RULES (1120+ members already BANNED for violation) 1) Use concise, accurate thread titles. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get quick attention or may not be answered. 2) Don't post a question in the thread of another member. 3) Don't post questions regarding breaking or bypassing any security measure. 4) Acknowledge the responses you receive, good or bad. 5) Cross-promotion of, or links to, forums competitive to this forum in signatures are prohibited. 6) Jobs posting is not allowed. 7) Sharing copyrighted ebooks/pirated ebooks/their links is not allowed. NOTE : Don't ever post personal or confidential data in a workbook. Forum owners and members are not responsible for any loss. --- You received this message because you are subscribed to the Google Groups "MS EXCEL AND VBA MACROS" group. To post to this group, send email to excel-macros@googlegroups.com. To unsubscribe from this group, send email to excel-macros+unsubscr...@googlegroups.com. Visit this group at http://groups.google.com/group/excel-macros?hl=en.