Looking for a formula to replace final comma

Hi all,

I’m looking for a formula that will take the final comma of a line annd replace it with an “and”. This is for use with the gmail pack, where I want to start an email with “Dear Alan and Gerry” rather than “Dear Alan, Gerry”.

Thanks all

You can accomplish this with regular expressions: find the comma-and-space sequence that has no more commas ahead, like this:

MyText.RegexReplace(",\s(?!.*,.*)", " and ")

And if you need an Oxford comma you can further check whether the input contains two or more elements in it.

8 Likes

Wow this is great stuff! Thank you!

That last column is really an Elegant solution!

2 Likes

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.