Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
clubin
 
Posts: n/a
Default Looking up a text string

I have an issue where I am trying to lookup certain text strings and return
values corresponding to the strings from a separate worksheet. However, the
strings do not match exactly on the worksheets. For example on the sheet
with the values to lookup it will list

"AAAA-BBBB"

but on the data worksheet it will have something like

"ZZAAAA-BBBB-YY

The text string is there, but using vlookup will not work as they do not
match exactly. In addition the lookup function doesn't seem to work as there
may be other strings in the data sheet such as

"AA-BB"

which is returned from the lookup function. Is there a way to find the
exact string within other strings as part of the array on the data sheet, or
is this not possible?

Please help.

Thank you,

Chaim
  #3   Report Post  
Posted to microsoft.public.excel.misc
Sloth
 
Posts: n/a
Default Looking up a text string

you can't do it using the lookup functions, but you might be able to do it
with the index function.

I experiment with the following list starting in A1.
123a-b45
123a-g45
a-v123456

using the following formula you can find the row number of the item
containing "a-g".
=SUMPRODUCT(--ISNUMBER(FIND("a-g",A1:A3)),ROW(A1:A3))
and if you wanted to match this number with an item in column B you could
use this formula...
=INDEX(B:B,SUMPRODUCT(--ISNUMBER(FIND("a-g",A1:A3)),ROW(A1:A3)))

This only works if the string is unique in the array. Other wise it will
return a funny number. You could use an if function using
=IF(SUMPRODUCT(--ISNUMBER(FIND("a-g",A1:A3)),ROW(A1:A3)/ROW(A1:3))=1,INDEX(B:B,SUMPRODUCT(--ISNUMBER(FIND("a-g",A1:A3)),ROW(A1:A3))),"error message")

For instance, if you had this list
123a-b45
123a-g45
a-v123456
123va-basd54

searching for "a-b" would give 5 (1+0+0+4) with the first formula I gave,
and searching for "45" would give 6 (1+2+3+0). Both of these searches would
return "error message" using the last formula.

You have a couple options depending on how you want to distinguish the
strings. Using the example you gave, how would you clarify that "AA-BB" is
not included in "AAAA-BBBB", but is included in something else like
"ZZAA-BB-YY"? Because the exact string is in both.

"clubin" wrote:

I have an issue where I am trying to lookup certain text strings and return
values corresponding to the strings from a separate worksheet. However, the
strings do not match exactly on the worksheets. For example on the sheet
with the values to lookup it will list

"AAAA-BBBB"

but on the data worksheet it will have something like

"ZZAAAA-BBBB-YY

The text string is there, but using vlookup will not work as they do not
match exactly. In addition the lookup function doesn't seem to work as there
may be other strings in the data sheet such as

"AA-BB"

which is returned from the lookup function. Is there a way to find the
exact string within other strings as part of the array on the data sheet, or
is this not possible?

Please help.

Thank you,

Chaim

  #5   Report Post  
Posted to microsoft.public.excel.misc
SteveG
 
Posts: n/a
Default Looking up a text string


This worked but only if AAAA-BBBB appears once in your list. Otherwise,
it will return the sum of each instance that AAAA-BBBB appears.

=SUMPRODUCT(--(ISNUMBER(FIND("AAAA-BBBB",C10:C13))),--(D10:D13))

Column C is where your text within text is and D is the value to
return.

Cheers,

Steve


--
SteveG
------------------------------------------------------------------------
SteveG's Profile: http://www.excelforum.com/member.php...fo&userid=7571
View this thread: http://www.excelforum.com/showthread...hreadid=496637



  #6   Report Post  
Posted to microsoft.public.excel.misc
SteveG
 
Posts: n/a
Default Looking up a text string


A small modification.

The only advantage to using this instead of the VLOOKUP is if you have
multiple lookup values, you can drag this formula down the list and not
have to change the lookup criteria manually for each lookup value. It
is also not case sensitive. Use FIND instead of SEARCH if case is
important.

=SUMPRODUCT(--(ISNUMBER(SEARCH(A1,$E$1:$E$4))),--($F$1:$F$4))

A1 is your lookup value. E is where the value is located and F is your
return value if TRUE.

Again, this only works if your lookup values only appear once in your
range.

HTH

Steve


--
SteveG
------------------------------------------------------------------------
SteveG's Profile: http://www.excelforum.com/member.php...fo&userid=7571
View this thread: http://www.excelforum.com/showthread...hreadid=496637

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Text string and sum michaelp Excel Worksheet Functions 4 November 14th 05 09:49 PM
Remove last character of text string Grant Excel Worksheet Functions 2 September 29th 05 05:17 PM
dynamic cell reference within a text string gvm Excel Worksheet Functions 4 July 25th 05 02:40 AM
Extracting from a text string AmyTaylor Excel Worksheet Functions 3 June 24th 05 01:34 PM
Formating a text string? METCO1 Excel Discussion (Misc queries) 2 November 30th 04 06:31 PM


All times are GMT +1. The time now is 07:59 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"