FIND function using a Define Name range

MsLeFox2017

New Member
Joined
Oct 23, 2017
Messages
5
Hi,

I'm using the below formula to extract data (equipment number) with a hyphen. For example, cell contains:

V-1770A BLAST/PAINT EXTERNAL SURFACE (#17337C)

the formula:

=TRIM(MID(SUBSTITUTE(E3080," ",REPT(" ",99)),MAX(1,FIND("V-",SUBSTITUTE(E3080," ",REPT(" ",99)))-50),99))

returns the results:

V-1770A

The formula works great, but I have to change the FIND find_text parameter (V- or I- or E- or C- or T-) each time the equipment number changes in the cell line. Examples of various cell data lines:

I-1602 A/B "DRYER" DEMO SCAFFOLD # 2080 (#17324A)
E-1403 "IN/OUTLET VALVE " DEMO SCAFFOLD #2076 (#17324A)
C-1407 "INSPECTION WINDOWS" REPLACE METAL/SEALANT (#17324B)
T-1311C "ROOF TOP NOZZLES" CLEAN/PAINT (#17324C)
V-1770A BLAST/PAINT EXTERNAL SURFACE (#17337C)

No matter where the information is on the line the formula works, but I have to edit the formula each time the equipment letter changes. I've tried using a Define Name table in the FIND find_text parameter, but that does not work. Returns #VALUE .

Any suggestions or help would be greatly appreciated.
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.

MsLeFox2017

New Member
Joined
Oct 23, 2017
Messages
5
Thanks for the reply. The current formula searches and finds the name anywhere in the cell for any length. Items bolded in the examples below is what needs extracting.

Examples:

C-1407 "INSPECTION WINDOWS" REPLACE METAL/SEALANT (#17324B)
"ROOF TOP NOZZLES" CLEAN/PAINT T-1311C (#17324C)
BLAST/PAINT V-1770A EXTERNAL SURFACE (#17337C)
T/A - T-1335 INTERNAL CLEANING (#17324D)
P-1353 "VALVES/PIPING" REMOVE & REPLACE INSULATION/METAL (#17324B)
T/A - T-1345A "NOZZLES" INSTALL PLASTIC PROTETION (#17324B)
"PSF DISK" SF-1160 REPLACE HEAT TRACING & INSULATION BLANKETS (#17324B)

<tbody>
</tbody><colgroup><col></colgroup>

<tbody>
</tbody><colgroup><col></colgroup>

I'm not sure as to where your suggestion would be placed in this formula:

=TRIM(MID(SUBSTITUTE(E3080," ",REPT(" ",99)),MAX(1,FIND("V-",SUBSTITUTE(E3080," ",REPT(" ",99)))-50),99))
where "V-" is the FIND find_text being changed each time a different piece of equipment is named.

The Define Name range I've tried to use is:

=TRIM(MID(SUBSTITUTE(E3080," ",REPT(" ",99)),MAX(1,FIND(Equip_Lookup,SUBSTITUTE(E3080," ",REPT(" ",99)))-50),99))
Equip_Lookup
C-
D-
DV-
F-
FI-C
FV-
LG-
LS-
LSHH-
LV-
ME-
OV-
P-
PSE-
PSV-
PV-
R-
SD-
T-
TCV-
TV-
V-
VB-
VJ-

<tbody>
</tbody><colgroup><col></colgroup>
 

Marcelo Branco

MrExcel MVP
Joined
Aug 23, 2010
Messages
16,653
Office Version
  1. 2019
  2. 2010
Platform
  1. Windows
What is the expected result for the last example?
SF-
is not present in Equip_lookup, but F- is.

M.
 

MsLeFox2017

New Member
Joined
Oct 23, 2017
Messages
5

ADVERTISEMENT

I'm still building the Equip_Lookup table. SF- and F- are two different types of equipment names. Thanks for asking.
 

MsLeFox2017

New Member
Joined
Oct 23, 2017
Messages
5
I'm still building the Equip_Lookup table. SF- and F- are two different types of equipment names. Thanks for asking.

Also, if there are characters before the search characters, those characters will be picked up as well. But, they would still be different records.
 

Marcelo Branco

MrExcel MVP
Joined
Aug 23, 2010
Messages
16,653
Office Version
  1. 2019
  2. 2010
Platform
  1. Windows

ADVERTISEMENT

I'm still building the Equip_Lookup table. SF- and F- are two different types of equipment names. Thanks for asking.

Ok, so assuming the last example should return an error ("Not Found"), until SF- is included in the named range, maybe something like that


A
B
1
Text​
Result​
2
C-1407 "INSPECTION WINDOWS" REPLACE METAL/SEALANT (#17324B)​
C-1407​
3
"ROOF TOP NOZZLES" CLEAN/PAINT T-1311C (#17324C)​
T-1311C​
4
BLAST/PAINT V-1770A EXTERNAL SURFACE (#17337C)​
V-1770A​
5
T/A - T-1335 INTERNAL CLEANING (#17324D)​
T-1335​
6
P-1353 "VALVES/PIPING" REMOVE & REPLACE INSULATION/METAL (#17324B)​
P-1353​
7
T/A - T-1345A "NOZZLES" INSTALL PLASTIC PROTETION (#17324B)​
T-1345A​
8
"PSF DISK" SF-1160 REPLACE HEAT TRACING & INSULATION BLANKETS (#17324B)​
Not Found​

Formula in B2 copied down
=IFERROR(TRIM(MID(SUBSTITUTE(A2," ",REPT(" ",99)),MAX(1,FIND(" "&LOOKUP(9.99E+307,SEARCH(Equip_Lookup,A2),Equip_Lookup)," "&SUBSTITUTE(A2," ",REPT(" ",99)))-50),99)),"Not Found")

Observe i substituted in your formula
TRIM(MID(SUBSTITUTE(E3080," ",REPT(" ",99)),MAX(1,FIND(Equip_Lookup,SUBSTITUTE(E3080," ",REPT(" ",99)))-50),99))

Equip_Lookup by LOOKUP(9.99E+307,SEARCH(Equip_Lookup,A2),Equip_Lookup)

and added a space before this LOOKUP, and another space before SUBSTITUTE (to avoid that the equipment whose prefix is F- is found in SF-)

Hope this helps

M.
 

admiral100

Well-known Member
Joined
Jan 17, 2015
Messages
873
It's very very long :)

=IF(LEFT(IF(LEN(LEFT(A1,IFERROR(SEARCH(" ??-",A1),SEARCH("?-",A1))))>=IFERROR(SEARCH(" ?-",A1),SEARCH("?-",A1)),SUBSTITUTE(LEFT(A1,IFERROR(SEARCH(" ??-",A1),SEARCH("?-",A1))),LEFT(A1,-2-LOOKUP(,-FIND("-",A1,ROW($1:$99)))),""),SUBSTITUTE(LEFT(A1,-1-LOOKUP(,-FIND("-",A1,ROW($1:$99)))),LEFT(A1,IFERROR(SEARCH(" ??-",A1),SEARCH("?-",A1))),""))&MID(A1,FIND("-",A1),FIND(" ",A1,FIND("-",A1))-FIND("-",A1)),3)="T/A",TRIM(MID(IF(LEN(LEFT(A1,IFERROR(SEARCH(" ??-",A1),SEARCH("?-",A1))))>=IFERROR(SEARCH(" ?-",A1),SEARCH("?-",A1)),SUBSTITUTE(LEFT(A1,IFERROR(SEARCH(" ??-",A1),SEARCH("?-",A1))),LEFT(A1,-2-LOOKUP(,-FIND("-",A1,ROW($1:$99)))),""),SUBSTITUTE(LEFT(A1,-1-LOOKUP(,-FIND("-",A1,ROW($1:$99)))),LEFT(A1,IFERROR(SEARCH(" ??-",A1),SEARCH("?-",A1))),""))&MID(A1,FIND("-",A1),FIND(" ",A1,FIND("-",A1))-FIND("-",A1)),6,LEN(IF(LEN(LEFT(A1,IFERROR(SEARCH(" ??-",A1),SEARCH("?-",A1))))>=IFERROR(SEARCH(" ?-",A1),SEARCH("?-",A1)),SUBSTITUTE(LEFT(A1,IFERROR(SEARCH(" ??-",A1),SEARCH("?-",A1))),LEFT(A1,-2-LOOKUP(,-FIND("-",A1,ROW($1:$99)))),""),SUBSTITUTE(LEFT(A1,-1-LOOKUP(,-FIND("-",A1,ROW($1:$99)))),LEFT(A1,IFERROR(SEARCH(" ??-",A1),SEARCH("?-",A1))),""))&MID(A1,FIND("-",A1),FIND(" ",A1,FIND("-",A1))-FIND("-",A1)))-5)),IF(LEN(LEFT(A1,IFERROR(SEARCH(" ??-",A1),SEARCH("?-",A1))))>=IFERROR(SEARCH(" ?-",A1),SEARCH("?-",A1)),SUBSTITUTE(LEFT(A1,IFERROR(SEARCH(" ??-",A1),SEARCH("?-",A1))),LEFT(A1,-2-LOOKUP(,-FIND("-",A1,ROW($1:$99)))),""),SUBSTITUTE(LEFT(A1,-1-LOOKUP(,-FIND("-",A1,ROW($1:$99)))),LEFT(A1,IFERROR(SEARCH(" ??-",A1),SEARCH("?-",A1))),""))&MID(A1,FIND("-",A1),FIND(" ",A1,FIND("-",A1))-FIND("-",A1)))
 

MsLeFox2017

New Member
Joined
Oct 23, 2017
Messages
5
@Marcelo Branco

:) Thank you. After researching the LOOKUP(9.99E+307... (BigNum) setting, I modified the formula, made adjustments to my lookup table, and it now works for what I need.:)

Final formula:
=IFERROR(TRIM(MID(SUBSTITUTE(E2993," ",REPT(" ",99)),MAX(1,FIND(LOOKUP(9.99E+307,SEARCH(Equip_Lookup,E2993),Equip_Lookup),SUBSTITUTE(E2993," ",REPT(" ",99)))-50),99))," ")

where the Define Name range (Equip_Lookup) had to be exact (no blank lines), with the specific search values. There are other cells which hold data with hyphens that were not valid elements of my search.

Should there be a new entry for the range, it must be inserted into the range, or added at the end, sorted, and the range size adjusted using Name Manager.

Again, thank you for your brilliance!
 

Forum statistics

Threads
1,136,258
Messages
5,674,672
Members
419,520
Latest member
Jennifer4Dillon

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
Top