VBA/Macro: Removing titles [Solved/Closed]

Report
-
 Austin -
Hello,

I need to remove Mr/Mrs/Miss preceeding the names in one cell and copy them to another cell. Any idea? Your advice is much appreciated.

ie.
In C2: Miss Jane Smith
Should be, in C3: Jane Smith

Austin

3 replies

Posts
1862
Registration date
Sunday June 14, 2009
Status
Contributor
Last seen
July 30, 2015
791
try this formula

=MID(C2,SEARCH(" ",C2)+1,LEN(C2)-SEARCH(" ",C2)+1)


this will work whatever be the tile in C2 Mr,Mrs or Miss etc. The logic is find the first blank(that is after the title) and use that position in the mid function.

type in C2
Mr john smith or Miss Gabriel smith
and see what happen in the formula cell
1
Thank you

A few words of thanks would be greatly appreciated. Add comment

CCM 2931 users have said thank you to us this month

Hello ventkat1926!

It works! Thank you. Another question though, what if I need the Jane Smith to show up on another sheet?


Austin
Posts
1862
Registration date
Sunday June 14, 2009
Status
Contributor
Last seen
July 30, 2015
791
you include sheets name before with an exclamation mark.

suppose Mr john smith is in sheet 1 cell C2

then in any other sheet and in any empty copy this formula

=MID(Sheet1!C2,SEARCH(" ",Sheet1!C2)+1,LEN(Sheet1!C2)-SEARCH(" ",Sheet1!C2)+1)
 


experiment with this formula
1
Thank you

A few words of thanks would be greatly appreciated. Add comment

CCM 2931 users have said thank you to us this month

Am trying this. Will get back to you. Thanks venkat1926!
Hi!

I got syntax error when I used it. Here's the entire code I'm working on:

Dim counter As Integer
Dim row As Integer
Dim strFormula As String

counter = 2
row = 2

Do Until IsEmpty(Sheets("ORG CHART").Range("A" & row))

If Sheets("ORG CHART").Range("E" & row) = "PERMANENT" Then
counter = counter + 1
Sheets("MASTER DATA").rows(counter).Columns("A").Value = Sheets("ORG CHART").rows(row).Columns("I").Value
Sheets("MASTER DATA").rows(counter).Columns("C").Value = Sheets("ORG CHART").rows(row).Columns("P").Value
Sheets("MASTER DATA").rows(counter).Columns("D").Value = Sheets("ORG CHART").rows(row).Columns("C").Value
Sheets("MASTER DATA").rows(counter).Columns("E").Value = Sheets("ORG CHART").rows(row).Columns("U").Value
Sheets("MASTER DATA").rows(counter).Columns("F").Value = Sheets("ORG CHART").rows(row).Columns("V").Value
Sheets("MASTER DATA").rows(counter).Columns("G").Value = Sheets("ORG CHART").rows(row).Columns("J").Value

strFormula = "=MID(Sheets("ORG CHART")!Range("K" & row),SEARCH(" ",Sheets("ORG CHART")!Range("K" & row)+1,LEN(Sheets("ORG CHART")!Range("K" & row))-SEARCH(" ",Sheets("ORG CHART")!Range("K" & row)+1)

Sheets("MASTER DATA").rows(counter).Columns("B").Value = strFormula

End If
row = row + 1
Loop

Help!
> Austin
Oh wait. I just forgot to place closing quotations in the formula.

But now I get a compile error (expected: end of statement) and the the ORG after ="MID(Sheets(" gets highlighted. Why is this?
Posts
1862
Registration date
Sunday June 14, 2009
Status
Contributor
Last seen
July 30, 2015
791
I have given a formula not a vba macro. it is little complex to use a formula with variable in vba

send a small extract of your date and what you want to be doen . attach .xls file to my email address through the administrator if allowed.
I seem to be permitted from seeing your email. Can you give me your email via this thread?

Thanks a lot!