I have been stuck on this all night and am looking for some suggestions. I essentially need to be able to find a character to the left of a string somewhere in the middle of a large text string so I can return a number value. The data is imported from an external database so I cannot change the format of the source data.
Here are a couple of cells of sample data (Referenced as the [@Spills] column in the code below). My problem is I need to extract the value of crude oil spilled, and subtract the value recovered. (In both the examples below the answer is zero: 0.8 m3 - 0.8 m3 =0, and 0.2 m3 - 0.2 m3 =0). I can get my formula to work if the Crude Oil is the first substance listed but I am having difficulty with the case that it is not the first substance listed.
[TABLE="width: 332"]
<tbody>[TR]
[TD="class: xl66, align: left"]0.8m3 CRUDE OIL (0.8m3 RECOVERED) | 4.0m3 SALT/PRODUCED WATER (4.0m3 RECOVERED)[/TD]
[/TR]
</tbody>[/TABLE]
[TABLE="width: 332"]
<tbody>[TR]
[TD="class: xl64, align: left"]0.0m3 WASTE (2.5m3 RECOVERED) | 0.2m3 CRUDE OIL (0.2m3 RECOVERED) | 0.1(1000m3) GAS PRODUCTION (RAW)[/TD]
[/TR]
</tbody>[/TABLE]
This is what I have so far:
I've underlined the text place holder for sections of the code I am stuck on above. I need to figure out how to search to the left of the CRUDE OIL substring to make this approach work. I'm also open to suggestions of alternate approaches to obtain the results I am looking for.
Here are a couple of cells of sample data (Referenced as the [@Spills] column in the code below). My problem is I need to extract the value of crude oil spilled, and subtract the value recovered. (In both the examples below the answer is zero: 0.8 m3 - 0.8 m3 =0, and 0.2 m3 - 0.2 m3 =0). I can get my formula to work if the Crude Oil is the first substance listed but I am having difficulty with the case that it is not the first substance listed.
[TABLE="width: 332"]
<tbody>[TR]
[TD="class: xl66, align: left"]0.8m3 CRUDE OIL (0.8m3 RECOVERED) | 4.0m3 SALT/PRODUCED WATER (4.0m3 RECOVERED)[/TD]
[/TR]
</tbody>[/TABLE]
[TABLE="width: 332"]
<tbody>[TR]
[TD="class: xl64, align: left"]0.0m3 WASTE (2.5m3 RECOVERED) | 0.2m3 CRUDE OIL (0.2m3 RECOVERED) | 0.1(1000m3) GAS PRODUCTION (RAW)[/TD]
[/TR]
</tbody>[/TABLE]
This is what I have so far:
Code:
=IF(SEARCH("CRUDE OIL",[@Spills])<11,VALUE(LEFT([@Spills], SEARCH("m3",[@Spills])-1)),VALUE(MID([@Spills], [U][I][B]Find the | left of CRUDE OIL[/B][/I][/U] +2, [U][I][B]Find the m3 left of CRUDE OIL[/B][/I][/U] - ([U][I][B]Find the | left of CRUDE OIL[/B][/I][/U] +2) )))-IFERROR(IF(MID([@Spills],SEARCH("CRUDE OIL",[@Spills])+10,1)="(",VALUE(MID([@Spills],SEARCH("CRUDE OIL",[@Spills])+11,SEARCH("m3",[@Spills],SEARCH("CRUDE OIL",[@Spills]))-SEARCH("(",[@Spills],SEARCH("CRUDE OIL",[@Spills]))-1)),0),0)
I've underlined the text place holder for sections of the code I am stuck on above. I need to figure out how to search to the left of the CRUDE OIL substring to make this approach work. I'm also open to suggestions of alternate approaches to obtain the results I am looking for.