Compare data within same cell

Psyanide

New Member
Joined
May 5, 2016
Messages
8
I require a macro code which compares data within same cell and accordingly provides status either "match found" or "mismatch"
I work on a discrepancy report and most of the property addresses are same only difference is abbreviations
eg. street = st, Road = rd and so on.

In the below example data on left side of "|||" is from 1 source and data on right side of "|||" is from other source
In the below example "A2" and "A3" are good to be deleted however "A4" has "drive" against "avenue" hence it needs to be verified.
Can you please provide me a macro code which would give me output as presented in "B" column based on the data on column "A"

Note: There are many such abbreviations I come across which I will add in the code by myself once I have the basic code.


[TABLE="width: 365"]
<colgroup><col><col><col></colgroup><tbody>[TR]
[TD] [/TD]
[TD]A[/TD]
[TD]B[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]Property Address[/TD]
[TD]Macro result[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]Apple Street ||| Apple St[/TD]
[TD]Delete[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]Blue Road colony ||| Blue Rd colony[/TD]
[TD]Delete[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]Sunshine Drive ||| Sunshine Avenue[/TD]
[TD]Check[/TD]
[/TR]
</tbody>[/TABLE]


Thanks :)
 
Within the For Loop, just put an if statement to check if the current cell's value is blank. Something like this:

Code:
For currRow = 1 To maxRow
        address = Cells(currRow, 1).Value
        If address = "" or address = " " Then
           'Whatever you want to do with blank cells, if you just want to ignore them, leave this as is
        Else
        add1 = address1(address)
        add2 = address2(address)
        If replaceAll(LCase(add1)) = replaceAll(LCase(add2)) Then
            Cells(currRow, 2).Value = "Delete"
        Else
            Cells(currRow, 2).Value = "Verify"
        End If
       End If
    Next
 
Upvote 0

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.

Forum statistics

Threads
1,223,234
Messages
6,170,891
Members
452,366
Latest member
TePunaBloke

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