Find and Replace Many

RyanWi

New Member
Joined
May 15, 2013
Messages
22
Hello,

I have an email database where it contains lot of Yahoo, Hotmail, Gmail and other email accounts in 1 column..
I want to filter and put the domain on the 2nd column.

So for an example:-
outlook.com, hotmail.com, live.com
email accounts should be named as HOTMAIL in front. (2nd column)

yahoo.com
ymail.com
should be as YAHOO

how can i get this done easily?
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
Hi,

Not entirely sure what you are looking for,

You can extract the domain using a MID formula, then you can look up the domain from a table using VLOOKUP or INDEX/MATCH. If you don't want to use lookup you could nest IF functions to convert outlook.com to HOTMAIL or maybe the easiest would be to add a pivot table and group the items as you want.

Here's the MID function to get the domain, where the email address would be in A2
=MID(A2,SEARCH("@",A2)+1,50)
 
Upvote 0
RyanWi,

Here is a macro solution for you to consider that will run in the active worksheet.

I assume that your raw data has titles in row 1.


Please TEST this FIRST in a COPY of your workbook (always make a backup copy before trying new code, you never know what you might lose).

1. Copy the below code
2. Open your NEW workbook
3. Press the keys ALT + F11 to open the Visual Basic Editor
4. Press the keys ALT + I to activate the Insert menu
5. Press M to insert a Standard Module
6. Where the cursor is flashing, paste the code
7. Press the keys ALT + Q to exit the Editor, and return to Excel
8. To run the macro from Excel press ALT + F8 to display the Run Macro Dialog. Double Click the macro's name to Run it.

Code:
Sub RyanWi()
' hiker95, 09/19/2017, ME1023315
Application.ScreenUpdating = False
Dim r As Range
With ActiveSheet
  For Each r In .Range("A2", .Range("A" & Rows.Count).End(xlUp))
    If InStr(r, "outlook") Or InStr(r, "hotmail") Or InStr(r, "live") Then r.Offset(, 1) = "HOTMAIL"
    If InStr(r, "Outlook") Or InStr(r, "Hotmail") Or InStr(r, "Live") Then r.Offset(, 1) = "HOTMAIL"
    If InStr(r, "yahoo") Or InStr(r, "ymail") Then r.Offset(, 1) = "YAHOO"
    If InStr(r, "Yahoo") Or InStr(r, "Ymail") Then r.Offset(, 1) = "YAHOO"
    If InStr(r, "Gmail") Or InStr(r, "gmail") Then r.Offset(, 1) = "GMail"
  Next r
End With
Application.ScreenUpdating = False
End Sub

Before you use the macro with Excel 2007 or newer, save your workbook, Save As, a macro enabled workbook with the file extension .xlsm, and, answer the "do you want to enable macros" question as "yes" or "OK" (depending on the button label for your version of Excel) the next time you open your workbook.

Then run the RyanWi macro.
 
Upvote 0
Wow!! This is what i was looking for!
Worked out Perfectly... Many Thanks!!!

RyanWi,

Here is a macro solution for you to consider that will run in the active worksheet.

I assume that your raw data has titles in row 1.


Please TEST this FIRST in a COPY of your workbook (always make a backup copy before trying new code, you never know what you might lose).

1. Copy the below code
2. Open your NEW workbook
3. Press the keys ALT + F11 to open the Visual Basic Editor
4. Press the keys ALT + I to activate the Insert menu
5. Press M to insert a Standard Module
6. Where the cursor is flashing, paste the code
7. Press the keys ALT + Q to exit the Editor, and return to Excel
8. To run the macro from Excel press ALT + F8 to display the Run Macro Dialog. Double Click the macro's name to Run it.

Code:
Sub RyanWi()
' hiker95, 09/19/2017, ME1023315
Application.ScreenUpdating = False
Dim r As Range
With ActiveSheet
  For Each r In .Range("A2", .Range("A" & Rows.Count).End(xlUp))
    If InStr(r, "outlook") Or InStr(r, "hotmail") Or InStr(r, "live") Then r.Offset(, 1) = "HOTMAIL"
    If InStr(r, "Outlook") Or InStr(r, "Hotmail") Or InStr(r, "Live") Then r.Offset(, 1) = "HOTMAIL"
    If InStr(r, "yahoo") Or InStr(r, "ymail") Then r.Offset(, 1) = "YAHOO"
    If InStr(r, "Yahoo") Or InStr(r, "Ymail") Then r.Offset(, 1) = "YAHOO"
    If InStr(r, "Gmail") Or InStr(r, "gmail") Then r.Offset(, 1) = "GMail"
  Next r
End With
Application.ScreenUpdating = False
End Sub

Before you use the macro with Excel 2007 or newer, save your workbook, Save As, a macro enabled workbook with the file extension .xlsm, and, answer the "do you want to enable macros" question as "yes" or "OK" (depending on the button label for your version of Excel) the next time you open your workbook.

Then run the RyanWi macro.
 
Upvote 0
Wow!! This is what i was looking for!
Worked out Perfectly... Many Thanks!!!

RyanWi,

Thanks for the feedback.

You are very welcome. Glad I could help.

And, come back anytime.
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,871
Members
452,363
Latest member
merico17

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