You have value in cell like skjfjkjdsf_38476_jflsjk. You should extract value between underscores, as that is the only interesting part in the cell.
It can be the case that there is only one underscore lkfjdsk_3945. Then digits after the underscore are to be extracted.

The first underscore is easy to find. Use the FIND formula. The arguments are what to find and where. The formula returns running number of the digit to be found. Underscore is 11th digit in the cell B3.
To find the second underscore is bit trickier. FIND formula has third argument is the character at which to start the search. If we start the search from 12th digit onwards, then the following underscore is the second underscore.

The formula in E3 holds three arguments:
- What to find “_”.
- Where to find in the cell B3.
- Where to start. Find the underscore and add one. As the underscore was find in 11th digit, then start find from 12 onwards.

However, if only one underscore exists, then the double FIND formula returns error message. This can be detected with ISERROR formula.

As the formula can not return a value, ISERROR returns TRUE, which looks better than #VALUE!.

Now we added IF-formula.
If the second underscore cannot be found and the ISERROR is true, then take the length of the cell plus one. If ISERROR is not true, the second underscore was found, then return the serial number of the second underscore.
Then we can finalize the sentence.

- MID function, starts with the first underscore plus one, meaning the next digit after the first underscore.
- Number of digits to be extracted by MID is either the second underscore or the length of the cell plus one. The serial number of the first underscore plus one is minused.
Let’s check the first row in more details.
The value in B2 is fjls_314_djf. The first underscore is 5th digit. The second underscore is found in 9th digit. The first underscore is 5th and plus one equals to 6. The formula is MID(B2; 6; (9-6)).
The value in B4 is fjls_3976. The first underscore is 5th digit. The second underscore is not found, so the IF-sentence returns the the length of the cell plus one, 10. The first underscore is 5th and plus one equals to 6. The formula is MID(B4; 6;(10-6)).
The sentence is here for copy pasting.
=MID(B2;(FIND(“_”;B2)+1);IF(ISERROR(FIND(“_”;B2;(FIND(“_”;B2)+1)));(LEN(B2)+1);(FIND(“_”;B2;(FIND(“_”;B2)+1))))-(FIND(“_”;B2)+1))
Already earlier I introduced VALUE function.

The issue is that even though the sentence returns correct values, they are not numbers and cannot be calculated directly.

However, if you frame the sentence with VALUE, you can directly calculate the results.
=VALUE(MID(B2;(FIND(“_”;B2)+1);IF(ISERROR(FIND(“_”;B2;(FIND(“_”;B2)+1)));(LEN(B2)+1);(FIND(“_”;B2;(FIND(“_”;B2)+1))))-(FIND(“_”;B2)+1)))

















