Forum Discussion

bts778's avatar
bts778
Copper Contributor
Nov 09, 2021

Separating By Comma Equation Doesn't Always Work

Hello! I am trying to create an automatic system for separating a set of names by comma. I realize that I can do text to columns, but I was requested to try and create an equation for this so that the names could simply be imported and and the names would populate without any steps. My file looks like this so far:

 

 

Each equation revolves around using the mid() and find() functions to locate the names and separate them by comma. an example for the the equation in the '3rd' column looks like this:

 

=IF(M8 > 1, IFERROR(LEFT(MID(MID($C8,FIND(", ",$C8)+1,256),FIND(", ",MID($C8,FIND(", ",$C8)+1,256))+1,256),FIND(", ",MID(MID($C8,FIND(", ",$C8)+1,256),FIND(", ",MID($C8,FIND(", ",$C8)+1,256))+1,256),1)-1),RIGHT(C8,FIND(", ",C8,1)+0)),"")

 

First off, is there a better way to do this? Because I imagine I might run into some problems running this on a large enough data set.

 

Second, basically, it does work, except sometimes, during an instance that I can't predict. For example, in cell 'G9' the name is supposed to read "Patrick M" but clearly does not. Similar issue in I11. The equation is the same for all cells in each column, so I have no idea why it works in some instances, but not others. The only difference is the source cell "Cx" and thus the source data. It's only the last name in the data set that gives problems too, which means that it has something to do with the 

 

RIGHT(C8,FIND(", ",C8,1)+0))

 

portion of the equation. It seems like a temporary fix is to adjust "+0" to different values, but I can't find a value that works for every name, all the time. I have also tried to add/remove the space after in the comma in the quotations. 

 

Any help on this is appreciated. 

 

 

 

 

Resources