Standardize names using formula or VBA Code (Help required)

Sandesh26

New Member
Joined
Apr 14, 2011
Messages
6
I am in big trouble here I want to Standardize names using macro or any excel function<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>
Standardize means in a row name is written in different fashion e.g. <o:p></o:p>
sandesh Chavan
mr rajesh
mr sandesh
chavan sandesh
Nilesh
m\r nilesh
saurabh
mr saurabh
akshay
Akshay Vaishnav
mr Mahesh
Mahesh (like wise there is thousands of data)
--------<o:p></o:p>
Now what I want is from the above the macro should pick few names & rename as below<o:p></o:p>
Sandesh Chavan
Nilesh Chavan
Akshay Vaishnav<o:p></o:p>
------------
How I am doing now is I put filter on names list use the filter as contains & I put *sandesh* keyword<o:p></o:p>
Whatever data papers, I rename those as Sandesh Chavan in new column.<o:p></o:p>
Appreciate your help<o:p></o:p>
Thanks
Sandesh Chavan
If any of the part is unclear please let me know i am happy to explain again<o:p></o:p>
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
87fHKl8TXOIpPCX71pQVng
link explain above

https://picasaweb.google.com/lh/photo/87fHKl8TXOIpPCX71pQVng?feat=directlink
 
Upvote 0
Based on the screenshot

Code:
Sub DB_Standardise()
Dim findItems As Long: findItems = Range("A" & Rows.Count).End(xlUp).Row
Dim foundItems As Long: foundItems = Range("E" & Rows.Count).End(xlUp).Row
Dim fndWhat As String
Dim repWhat As String
Dim foundWhat As Range
Dim i As Long, j As Long
For i = 1 To findItems
    fndWhat = Range("A" & i).Value
    repWhat = Range("B" & i).Value
        For j = 1 To foundItems
            If LCase(Range("E" & j)) Like "*" & fndWhat & "*" Then
                Range("E" & j).Offset(, 1) = repWhat
            End If
        Next j
Next i
Range("F1:F" & foundItems).SpecialCells(xlCellTypeBlanks) = "Not Required"

End Sub
 
Upvote 0
I use office 2003

Excellent!!!!! Dave

I owe you!!!! ;)
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>
 
Upvote 0
Dear Dave 3009,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>
<o:p></o:p>
Thanks a million for these codes but it won’t work in all the cases. eg. Below<o:p></o:p>
<o:p></o:p>
Name in a column is "Emeraude International" & the keyword is *Emeraude* like wise "Adm International Sarl" & keyword is *Adm* <o:p></o:p>
<o:p></o:p>
I have slightly modified the code as per my requirement.<o:p></o:p>
<o:p> </o:p>
Adjustment is names to sanitised are kept in Tab one (namely: DataSheet) & The keywords to match are kept in Tab 2 (Namely : Keywords)<o:p></o:p>
<o:p> </o:p>
Can please let me know if am doing anything wrong<o:p></o:p>
<o:p> </o:p>
<o:p> </o:p>
Sub DB_Standardise()<o:p></o:p>
<o:p> </o:p>
Dim findItems As Long: findItems = Sheets("Keywords").Range("A" & Rows.Count).End(xlUp).Row<o:p></o:p>
Dim foundItems As Long: foundItems = Sheets("DataSheet").Range("A" & Rows.Count).End(xlUp).Row<o:p></o:p>
Dim fndWhat As String<o:p></o:p>
Dim repWhat As String<o:p></o:p>
Dim foundWhat As Range<o:p></o:p>
Dim i As Long, j As Long<o:p></o:p>
For i = 1 To findItems<o:p></o:p>
fndWhat = Sheets("Keywords").Range("A" & i).Value<o:p></o:p>
repWhat = Sheets("Keywords").Range("B" & i).Value<o:p></o:p>
For j = 1 To foundItems<o:p></o:p>
If LCase(Range("A" & j)) Like "*" & fndWhat & "*" Then<o:p></o:p>
Range("A" & j).Offset(, 1) = repWhat<o:p></o:p>
End If<o:p></o:p>
Next j<o:p></o:p>
Next i<o:p></o:p>
Range("B1:B" & foundItems).SpecialCells(xlCellTypeBlanks) = ""<o:p></o:p>
<o:p> </o:p>
Range("B1") = "Regularize name"<o:p></o:p>
<o:p> </o:p>
End Sub<o:p></o:p>
 
Upvote 0

Forum statistics

Threads
1,224,590
Messages
6,179,762
Members
452,940
Latest member
rootytrip

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