How to count array size when using split function?

Danny Reader
Danny Reader used Ask the Experts™
I have a field (FullNameField) with various name formats:

Mr. John Smith
Mrs. Sally E. Jones
Rick Stevens
Pat Allen Williams

I can use the following formula to separate and identify the various parts of the name:

stringVar array x;
x := Split({FullnameField});
x[1]; //output first array element

I want to create new fields for Title, First Name, Middle Name, Last Name.  Is there a way to count the total number of array elements so it can be determined which field it should go in?
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Senior Consultant
Most Valuable Expert 2011
Top Expert 2013
Use UBound(x)

That returns the upper bound of the array

x[UBound(x)] is the last name

To parse it properly will reuquire more than the number of elements

Danny ReaderDirector of Advancement Services


Finding the last element in the array won't help me.

If I can find out how many total elements are in the array along with a check to see if the first element is Mr. Mrs. or Ms. then I can determine if my Title formula should be the first array element or blank.  Then my First Name formula would display the first array element only if it is not Mr. Mrs. or Ms. etc.

At least that's the plan, I just need to get the array size for each name and I'll see if this could work.  Any suggestions on another approach would be greatly appreciated.  Thanks!

mlmcc has already given you the way to find out how many elements are in an array

UBound(x) or Count(x) both return the number of elements in an array
Danny ReaderDirector of Advancement Services


Thansk mlmcc, I should have read your suggestion more closely...the answer was there.  I initially tried x[UBound(x)] to get the last name.

UBound(x) is indeed the solution.  Thanks again!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial