Hey, I am wanting to find specific text in a column and return a specific value depending upon what is found in the cell. See the text box inside the attached for a detailed explanation on what I am looking for.
Many thanks!
Mitch
![]() |
Patch reliability is unclear. Unless you have an immediate, pressing need to install a specific patch, don't do it. |
SIGN IN | Not a member? | REGISTER | PLUS MEMBERSHIP |
Home » Forums » AskWoody support » Productivity software by function » MS Excel and spreadsheet help » Find Specific Text in Cell and Return a Specific Value
Mitch,
Here is a UDF to achieve what you want:
In a standard module:
Public Function DESC(rng As Range) As Integer If InStr(1, rng, “83”, vbTextCompare) > 0 Then DESC = 85:: Exit Function If InStr(1, rng, “85”, vbTextCompare) > 0 Then DESC = 85:: Exit Function If InStr(1, rng, “100”, vbTextCompare) > 0 Then DESC = 100:: Exit Function If InStr(1, rng, “120”, vbTextCompare) > 0 Then DESC = 120:: Exit Function DESC = 85 End Function
In Cell F2 =DESC(D2) then copy down
HTH,
Maud
Maud’s UDF is best, but this ugly formula will extract the number from the cell (fill down).
=IFERROR(–MID(D2,MIN(FIND({0,1,2,3,4,5,6,7,8,9},D2&”0123456789″)),FIND(” “,D2,MIN(FIND({0,1,2,3,4,5,6,7,8,9},D2&”0123456789″)))-MIN(FIND({0,1,2,3,4,5,6,7,8,9},D2&”0123456789″))),””)
This also assumes that if there’s a number, there is a space after it.
As far as I can see, the logic boils down to:
If there’s 100, return 100; if there’s 120, return 120; otherwise return 85. In which case, E2 could contain:
=IF(ISNUMBER(FIND(100,D3)),100,IF(ISNUMBER(FIND(120,D3)),120,85))
and copy down.
Or in E2:
=IFERROR(LOOKUP(1E+100,FIND({100,120},D2),{100,120}),85)
Donations from Plus members keep this site going. You can identify the people who support AskWoody by the Plus badge on their avatars.
AskWoody Plus members not only get access to all of the contents of this site -- including Susan Bradley's frequently updated Patch Watch listing -- they also receive weekly AskWoody Plus Newsletters (formerly Windows Secrets Newsletter) and AskWoody Plus Alerts, emails when there are important breaking developments.
Welcome to our unique respite from the madness.
It's easy to post questions about Windows 11, Windows 10, Win8.1, Win7, Surface, Office, or browse through our Forums. Post anonymously or register for greater privileges. Keep it civil, please: Decorous Lounge rules strictly enforced. Questions? Contact Customer Support.
Want to Advertise in the free newsletter? How about a gift subscription in honor of a birthday? Send an email to sb@askwoody.com to ask how.
Mastodon profile for DefConPatch
Mastodon profile for AskWoody
Home • About • FAQ • Posts & Privacy • Forums • My Account
Register • Free Newsletter • Plus Membership • Gift Certificates • MS-DEFCON Alerts
Copyright ©2004-2025 by AskWoody Tech LLC. All Rights Reserved.