Validating External Data

caritx

New Member
Joined
Dec 1, 2009
Messages
34
I know this will sound silly and I have googled and driven myself crazy because the problem seems so minor.

I get external files that sometimes have salutations:

Mr, Mr., Mrs, Mrs., Miss, Ms, Ms.,Dr, Dr.

The database I feed it to only takes: Mr., Mrs., Ms., Miss, Dr.

So I need an easy way to incorporate this into my macro:

If not one of these values (Mr., Ms., Mrs., Miss, Dr.) clear the cell.

Thank you in advance for any help you can provide.
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
Try something like this.
Code:
    For Each cell In Range("A1", Range("A" & Rows.Count).End(xlUp))
        
        Select Case cell.Value
            Case "Mr.", "Mrs.", "Ms.", "Miss", "Dr."
            Case Else: cell.ClearContents
        End Select
        
    Next cell
 
Upvote 0
Glad it works for you.
This will add a period if the cell is Mr, Mrs, Ms, or Dr
Otherwise it clears the cell.

Code:
    For Each Cell In Range("A1", Range("A" & Rows.Count).End(xlUp))
        
        Select Case Cell.Value
            Case "Mr.", "Mrs.", "Ms.", "Miss", "Dr."
            [COLOR="Red"]Case "Mr", "Mrs", "Ms", "Dr": Cell.Value = Cell.Value & "."[/COLOR]
            Case Else: Cell.ClearContents
        End Select
        
    Next Cell
 
Upvote 0

Forum statistics

Threads
1,224,586
Messages
6,179,729
Members
452,939
Latest member
WCrawford

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