Comparing strings with the percentage difference for Google Sheets.

yeat

New Member
Joined
Jan 25, 2022
Messages
18
Office Version
  1. 2019
Platform
  1. Windows
DESCRIPTION KEY IN BY HANDDESCRIPTION FROM BANKDESCRIPTION FROM BANK
THUNDER FOUR BY FOUR SDNTHUNDER FOUR BY FOUR SDN.Cn alliedTyre
SW AUTO TYRE SDN. BHD.SW AUTO TYRE SDN. BHD. 11111111122759118014
YONG SHENG ENTERPRISE SBXXXXXX8800 YONG SHENG ENTERPRISE SBYONG SHENG ENT SB
SALARY 0822XXXXXX1422 Tn WE ESALARY 0822
SALARY 0822TN WE SG/HE WI LGSALARY 0822
UTILITY 0722XXXXXX5029 CHEN MN CHiUTILITY 0722

Cell a: is the data I key by hand
Cell c&d: is the data from the bank

I want to compare these two cells and return a matching percentage. I intend to make if the percentage is less than 0.5, then A will be highlighted.

I just wanted to make certain that the description I typed was almost identical to the bank's description.
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
What % would you expect, for example, line 3 ("YONG SHENG...") and 5 ("SALARY 0822")?
and how?
 
Upvote 0
What % would you expect, for example, line 3 ("YONG SHENG...") and 5 ("SALARY 0822")?
and how?
LINE 3 = 100%
LINE 5 = 100%also (but I don't know is it possible)

for line 3
YONG SHENG ENTERPRISE SBXXXXXX8800 YONG SHENG ENTERPRISE SBYONG SHENG ENT SB
100% , 75%
then choose a higher rate, 100%
 
Upvote 0
first shot:
for testing, % will be in column E
VBA Code:
Option Explicit
Sub test()
Dim lr&, i&, p As Double, rng, arr(), max As Double
Dim ce As String, ceA As String, ceB As String
lr = Cells(Rows.Count, "A").End(xlUp).Row
rng = Range("A1:D" & lr).Value
For i = 1 To lr
    ce = Trim(rng(i, 1)): ceA = Trim(rng(i, 3)): ceB = Trim(rng(i, 4))
    If ce <> "" Then
        p = 0: max = 0
        If InStr(1, ceA, ce) Then
            p = (UBound(Split(ce)) + 1) / (UBound(Split(ceA)) + 1)
            If p > max Then max = p
        End If
        If InStr(1, ceB, ce) Then
            p = (UBound(Split(ce)) + 1) / (UBound(Split(ceB)) + 1)
            If p > max Then max = p
        End If
        Cells(i, "E").Value = max
    End If
Next
End Sub
Book1
ABCDE
1THUNDER FOUR BY FOUR SDNTHUNDER FOUR BY FOUR SDN.Cn alliedTyre83%
2SW AUTO TYRE SDN. BHD.SW AUTO TYRE SDN. BHD. 1111111112275911801483%
3YONG SHENG ENTERPRISE SBXXXXXX8800 YONG SHENG ENTERPRISE SBYONG SHENG ENT SB80%
4SALARY 0822XXXXXX1422 Tn WE ESALARY 0822100%
5SALARY 0822TN WE SG/HE WI LGSALARY 082233%
6UTILITY 0722XXXXXX5029 CHEN MN CHiUTILITY 0722100%
7
8
9
10
11
12
13
14
15
16
17
18
Sheet1
 
Upvote 0
It's not perfect, but it's awesome. Can you explain it, please? I would like to remodel it. I actually work with Google Sheet, seems a little too late to say. xD
 
Upvote 0

Forum statistics

Threads
1,223,323
Messages
6,171,455
Members
452,405
Latest member
DiamondHand_Jo

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top