Struggling with mid/find

dommmm

New Member
Joined
Feb 6, 2020
Messages
10
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2013
Platform
  1. Windows
Hi,
I'm wondering how best to approach this...

1621630084948.png


The formula I have in I2 is:

=IF(RIGHT(H2,5)="00000",IF(ISERROR(MID(F2,FIND("LOCDIFF",F2)+9,FIND(":",F2,FIND("LOCDIFF",F2))-FIND("LOCDIFF",F2)-12)),H2,MID(F2,FIND("LOCDIFF",F2)+9,FIND(":",F2,FIND("LOCDIFF",F2))-FIND("LOCDIFF",F2)-12)),"")

Basically - if the number in column H ends with 5 zeros, then I want it to find return the number (without the preceding - ) in F after "LOCDIFF" . It works fine until there's 2 "LOCDIFF" (the highlighted ones)
(the ISERROR copes with any that don't have LOCDIFF in F)

Advice much appreciated as it's giving me a headache!
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Can you please post some sample data.

MrExcel has a tool called “XL2BB” that lets you post samples of your data that will allow us to copy/paste it to our Excel spreadsheets, so we can work with the same copy of data that you are. Instructions on using this tool can be found here: XL2BB Add-in

Note that there is also a "Test Here” forum on this board. This is a place where you can test using this tool (or any other posting techniques that you want to test) before trying to use those tools in your actual posts.
 
Upvote 0
Maybe:

=IF(RIGHT(H2,5)="00000",TRIM(MID(SUBSTITUTE(F2," ",REPT(" ",99)),FIND("-",SUBSTITUTE(F2," ",REPT(" ",99)))+1,99)),"")

It finds the string between the - and the next space.
 
Upvote 0

Forum statistics

Threads
1,223,952
Messages
6,175,595
Members
452,657
Latest member
giadungthienduyen

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top