Go Back   TechArena Community > Software > Windows Software
Become a Member!
Forgot your username/password?
Register Tags Active Topics RSS Search Mark Forums Read

Sponsored Links



How to compare text string of two different columns in Excel

Windows Software


Reply
 
Thread Tools Search this Thread
  #1  
Old 06-01-2012
Member
 
Join Date: Dec 2011
Posts: 64
How to compare text string of two different columns in Excel
  

Hi friends recently I am trying to make the macros in Excel so that I compare the two different texts String Present in two different cells of two different columns in Excel, but however I am not able to create such tough macros or formula that I can make use. So if you guys have any ideas then please let me know.

Reply With Quote
  #2  
Old 06-01-2012
Member
 
Join Date: May 2011
Posts: 520
Re: How to compare text string of two different columns in Excel

Try this logic may it help you to make the comparison of two different Text string in Excel
Quote:
Dim TopMatch As Integer
Dim strCompare As String
Function Fuzzy(strIn1 As String, strIn2 As String) As Single
Dim L1 As Integer
Dim In1Mask(1 To 24) As Long 'strIn1 is 24 characters max
Dim iCh As Integer
Dim N As Long
Dim strTry As String
Dim strTest As String

TopMatch = 0
L1 = Len(strIn1)
strTest = UCase(strIn1)
strCompare = UCase(strIn2)

For iCh = 1 To L1
In1Mask(iCh) = 2 ^ iCh
Next iCh

For N = 2 ^ (L1 + 1) - 1 To 1 Step -1
strTry = ""
For iCh = 1 To L1
If In1Mask(iCh) And N Then
strTry = strTry & Mid(strTest, iCh, 1)
End If
Next iCh
If Len(strTry) > TopMatch Then TestString strTry
Next N
Fuzzy = TopMatch / CSng(L1)
End Function
And this sub procedure

Quote:
Sub TestString(strIn As String)
Dim L As Integer
Dim strTry As String
Dim iCh As Integer
L = Len(strIn)
If L <= TopMatch Then Exit Sub

strTry = "*"

For iCh = 1 To L
strTry = strTry & Mid(strIn, iCh, 1) & "*"
Next iCh

If strCompare Like strTry Then
If L > TopMatch Then TopMatch = L
End If
End Sub
Reply With Quote
  #3  
Old 06-01-2012
Member
 
Join Date: May 2011
Posts: 410
Re: How to compare text string of two different columns in Excel

Even I was also confused and make the several attempts for creating these Programs but finally I have created a function that will work for this query.
Function FrstLtrs(str As String) As String

Quote:
Dim temp
Dim i As Long
temp = Split(Trim(str))
For i = 0 To UBound(temp)
FrstLtrs = FrstLtrs & Left(temp(i), 1)
Next i
Max
Reply With Quote
  #4  
Old 06-01-2012
Member
 
Join Date: Jun 2011
Posts: 796
Re: How to compare text string of two different columns in Excel

The above works but there is need to make some changes that you have to modify
Quote:
Function FrstLtrs(str As String) As String
Dim temp
Dim i As Long
temp = Split(Trim(str))
For i = 0 To UBound(temp)
FrstLtrs = FrstLtrs & Left(temp(i), 1)
Next i
End Function
May this will be the correct function that works.
Reply With Quote
Reply

  TechArena Community > Software > Windows Software
Tags: , , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "How to compare text string of two different columns in Excel"
Thread Thread Starter Forum Replies Last Post
Find the number of text repeated in columns of Excel Jigisha MS Office Support 4 24-02-2012 03:35 PM
How can I split a text to different columns in Microsoft Excel Urjavaha MS Office Support 2 15-02-2012 07:17 PM
My Text are overlapping with other columns in Excel RajiI MS Office Support 4 27-01-2012 06:20 PM
How to compare two Date values in two different columns of a table Ehtesham SIddiqui Windows Software 1 06-10-2011 11:32 AM
How to compare two columns from different worksheet Ameya Windows Software 3 27-04-2009 11:34 PM


All times are GMT +5.5. The time now is 11:49 PM.