I am trying to create a function that will truncate a string. I am using 64-bit MS Excel 2013 Pro. This function will be used with over 6,000 cells each containing lots of data.
I am truncating from the left in a non-case sensitive manner:
Cell C2 =IFERROR(RIGHT(B2,LEN(B2)-SEARCH({"weight:*grams"},B2)+1),"")
Followed truncating from the right also in a non-case sensitive manner:
Cell D2 =IFERROR(LEFT(C2,SEARCH({"gram"},C2)+4),"")
(I'd like to later nest these two functions for simplicity.)
This pair of functions yields results such as:
Weight: 4.2 grams
Weight: 33.7 grams
Weight: 20 grams
Weight: 6.00 grams
But due to the earlier occurrence of "Weight:" in many entries this approach will also yield:
WEIGHT: 0.05 CTW RING SIZE: 7 WEIGHT: 1.9 grams
...and similar results that haven't been adequately truncated on the left.
For the first equation, I've tried to use the ? wildcard instead of * by:
1) adding additional case values within the brackets ( { } )
2) nesting IFERROR functions
But ...
the first approach is yielding FALSE if the first case value is not true, regardless of the validity of the subsequent cases
and ...
the second approach is yielding #Value! errors if the first case is not true, regardless of the validity of the subsequent cases.
This would be a powerful data mining tool for folks to add to their collection if only I could make a little more robust. Any ideas?
I am truncating from the left in a non-case sensitive manner:
Cell C2 =IFERROR(RIGHT(B2,LEN(B2)-SEARCH({"weight:*grams"},B2)+1),"")
Followed truncating from the right also in a non-case sensitive manner:
Cell D2 =IFERROR(LEFT(C2,SEARCH({"gram"},C2)+4),"")
(I'd like to later nest these two functions for simplicity.)
This pair of functions yields results such as:
Weight: 4.2 grams
Weight: 33.7 grams
Weight: 20 grams
Weight: 6.00 grams
But due to the earlier occurrence of "Weight:" in many entries this approach will also yield:
WEIGHT: 0.05 CTW RING SIZE: 7 WEIGHT: 1.9 grams
...and similar results that haven't been adequately truncated on the left.
For the first equation, I've tried to use the ? wildcard instead of * by:
1) adding additional case values within the brackets ( { } )
2) nesting IFERROR functions
But ...
the first approach is yielding FALSE if the first case value is not true, regardless of the validity of the subsequent cases
and ...
the second approach is yielding #Value! errors if the first case is not true, regardless of the validity of the subsequent cases.
This would be a powerful data mining tool for folks to add to their collection if only I could make a little more robust. Any ideas?