4

Is there a simple way to do this using only one arrayed formula?

enter image description here

Here are the names listed in the above image:

NAME
dela Cruz, Antonio Karl Jr.
Woods, Oliver
Hasegawa, Ken Sr.
Sta. Maria, Jennifer III
Smith, Nicole
Martin, John Edward
Hill, Cherry
Hala-an, James
Carter, Jay-ar

Your help will be greatly appreciated. Thank you so much in advance!

1
  • PS.: The names mentioned in the question are just sample made-up-names based on the hundreds of names I have encountered so far.
    – JDD
    Mar 24, 2022 at 9:31

1 Answer 1

6

Delete everything from B:B (including the header) and try this formula in B1:

=ArrayFormula({"Reformatted Name";IF(A2:A="",,TRIM(REGEXREPLACE(REGEXREPLACE(A2:A,"Jr$|Jr.$|Sr$|Sr.$|I$|II$|III$|IV$|Esq$|Esq.$",""),"([^,]+),\s*(.+$)","$2 $1"))&IFERROR(" "&REGEXEXTRACT(A2:A,"Jr$|Jr.$|Sr$|Sr.$|I$|II$|III$|IV$|Esq$|Esq.$")))})

This formula is written to handle the name cases you've shown and a few additional suffixes. If a name does not fit one of those formats, it should be returned in its original form.

If you find that you run into additional suffixes that aren't already included, just add them to the two lists within the formula, using a pipe symbol | as the separator.

If you want to change the header text, you will need to do so within the formula itself, not in cell B1.

4
  • woooowww Y_Y Once again, thank you so much, Sir. @Erik Tyler !!!! Y_Y... I'm really in tears right now, in all seriousness. I've been struggling with these formulae problems for months and I am doing this for my voluntary work in my place. I really don't have an idea about all of these, I've tried combining the formulas I have found online, like MID, SEARCH, REGEXs, etc. They kinda work, but in some names, they just don't work and I got some rumbled results plus the formulas I have made are really long, it's like a novel. So your help means a lot, Sir. Bless you, Sir, Bless you always!
    – JDD
    Mar 24, 2022 at 13:12
  • I wish to learn all of these, especially the regular expressions that I am having a hard time understanding, but I don't know where to start. If there are any advice you could give me, or free online resources you could recommend, it will be a very big help. hehe, I don't have much, that's why I'm just looking for free resources. hehe ^^' Once again, thank you so much, Sir!
    – JDD
    Mar 24, 2022 at 13:18
  • 2
    You're welcome. Glad I could help save you some tears. If you google "regex cheat sheet," you'll find some good places to start. From there, just experiment with each piece until you feel comfortable and then add another. I say this a lot. Everyone who knows anything about anything learned it essentially the same way: from the beginning and one piece at a time. Same as you will. We all started somewhere.
    – Erik Tyler
    Mar 24, 2022 at 23:25
  • Awesome 💕 Once again thank you so much, sir @Erik for everything! Apologies for not being able to reply right away 🙈 Always have a prosperous and great day!
    – JDD
    Apr 9, 2022 at 20:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.