AnsweredAssumed Answered

Remove Value from List (Custom Function)?

Question asked by lymetyme24 on Oct 11, 2016
Latest reply on Oct 31, 2016 by lymetyme24

Hoping to find a custom function that will search a list for a value and remove a set number of occurrences of that value from the list (not all the occurrences of it).

 

For example, if current list is:

 

Apple

Banana

Apple

Apple

Orange

 

Let's say I want to remove one occurrence of Apple, I would want to be able to diminish the list to just:

 

Apple

Banana

Apple

Orange

 

In my mind, the final custom function would look something like:  ListOccurrences ( list ; value ; count )

 

I started trying to accomplish this through a script and it started to get really long, my approach was to:

 

- determine how many times the value occurrs in the list (in my example above, "Apple" occurs 3x)

- remove ALL occurrences of the value from the list

- put the value back into the list the desired amount of times (count)

 

Seems like somewhere between the Substitute function and the custom function AddRemoveListItems (http://www.briandunning.com/cf/1178) there has gotta be a way to do this via Custom Function maybe?  Perhaps you all (smarter than me) can help?

Outcomes