Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Junior Member
 
Posts: 2
Default combine three if functions

Hi there this is my first post, i can normally work thing out by going through the forums and tweaking my stuff but im stuck. here is the problem.

i have 3 formulas that work on their own
=IF(ISNUMBER(SEARCH("a",F23)),VLOOKUP(A23,Sheet2!$ A$1:$A$1000:Sheet2!$K$1:$K$1000,9,FALSE),"")

=IF(ISNUMBER(SEARCH("b",F23)),VLOOKUP(A23,Sheet2!$ A$1:$A$1000:Sheet2!$K$1:$K$1000,10,FALSE),"")

=IF(ISNUMBER(SEARCH("c",F23)),VLOOKUP(A23,Sheet2!$ A$1:$A$1000:Sheet2!$K$1:$K$1000,11,FALSE),"")

what i think they say is that if cell f23 contains "a" look up data from cell a23 and insert correct cell from sheet 2.

now this works well if only i didnt need to combine them

what i need is this

if f23 contains a do the vlookup in column 9 if b use column 10 if c use column 11 if 9,10&11 blank leave cell blank

what i came up with is

=IF(ISNUMBER(SEARCH("a",F27)),VLOOKUP(A27,Sheet2!$ A$1:$A$1000:Sheet2!$K$1:$K$1000,9,FALSE),IF(ISNUMB ER(SEARCH("b",F27)),VLOOKUP(A27,Sheet2!$A$1:$A$100 0:Sheet2!$K$1:$K$1000,10,FALSE),IF(ISNUMBER(SEARCH ("c",F27)),VLOOKUP(A27,Sheet2!$A$1:$A$1000:Sheet2! $K$1:$K$1000,11,FALSE),"")))

this works for a and b but not c and deos not leave blank brings up the answer to b.


please can anyone help
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 829
Default combine three if functions

"robmin1983" wrote:
=IF(ISNUMBER(SEARCH("a",F27)),VLOOKUP(A27,Sheet2!$ A$1:$A$1000:Sheet2!$K$1:$K$1000,9,FALSE),IF(ISNUMB ER(SEARCH("b",F27)),VLOOKUP(A27,Sheet2!$A$1:$A$100 0:Sheet2!$K$1:$K$1000,10,FALSE),IF(ISNUMBER(SEARCH ("c",F27)),VLOOKUP(A27,Sheet2!$A$1:$A$1000:Sheet2! $K$1:$K$1000,11,FALSE),"")))

this works for a and b but not c and deos not leave blank brings up the
answer to b.


Off-hand, I do not see why that would not work as intended. I will keep
looking. Some thoughts....

Did you copy-and-paste from the Formula Bar into your posting?

If not, you might have unconsciously fixed the problem when you retyped it.

One comment.... The range Sheet2!$A$1:$A$1000:Sheet2!$K$1:$K$1000 can be
written more simply as Sheet2!$A$1:$K$1000. Simplifying formulas makes them
more readable, and it is easier to see mistakes.

Another comment.... Do you really need to do searches? Are the characters
"a", "b" and "c" in the same place in F27 all the time?

Even if they are not, I am tempted to suggest the following (untested):

=IF(COUNTIF(F27,"*a*")+COUNTIF(F27,"*b*")+COUNTIF( F27,"*c*")0,
VLOOKUP(A27,Sheet2!$A$1:$K$1000,9+COUNTIF(F27,"*b* ")+2*COUNTIF(F27,"*c*"),FALSE),"")

That assumes that the presence of "a", "b" and "c" in F27 is
mutually-exclusive. That is, only one of those characters (if any) will be
present in F27 at a time.

I say that I am "tempted" because even though that formula is shorter and
perhaps easier to read, it is less efficient. On the other hand, you might
not notice the performance difference. It's a judgment call.

Final comment.... What version of Excel are you using? Will your VLOOKUP
always succeed as long as "a", "b" or "c" is present in F27?

If not, the simpler formula above makes it easier to handle the VLOOKUP
error. But exactly how depends on whether you need Excel 2003
compatibility, or if we can assume Excel 2007 and later.

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 829
Default combine three if functions

PS.... I wrote:
"robmin1983" wrote:
=IF(ISNUMBER(SEARCH("a",F27)),VLOOKUP(A27,Sheet2!$ A$1:$A$1000:Sheet2!$K$1:$K$1000,9,FALSE),IF(ISNUMB ER(SEARCH("b",F27)),VLOOKUP(A27,Sheet2!$A$1:$A$100 0:Sheet2!$K$1:$K$1000,10,FALSE),IF(ISNUMBER(SEARCH ("c",F27)),VLOOKUP(A27,Sheet2!$A$1:$A$1000:Sheet2! $K$1:$K$1000,11,FALSE),"")))

this works for a and b but not c and deos not leave blank brings up the
answer to b.


Off-hand, I do not see why that would not work as intended. I will keep
looking.


I confirmed that the formula works for "c" as well as "a" and "b" exactly as
you entered it in your posting.

Again, I suspect the problem (our inability to reproduce your error) is that
you retyped the formula instead of copy-and-pasting from the Formula Bar,
and you unconsciously correct the original error.

Potential remedy: simply copy-and-paste from your posting back into Excel,
as I did.


I wrote:
Will your VLOOKUP always succeed as long as "a", "b" or "c"
is present in F27?


If so, is Sheet2!A1:A1000 sorted in ascending order?

If so, it would be better to use VLOOKUP(...,TRUE) instead of
VLOOKUP(...,FALSE).

It is a difference between a max of 10 comparisons v. an average of 500 and
a max of 100 comparisons. The difference can be noticable if you are
copying this formula down a long column.

  #4   Report Post  
Junior Member
 
Posts: 2
Smile

Thanks for some reason my excel did not like my original formula but your count if worked like a charm. just had to remove a space towards the end after "*b*"

thanks again
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
How do I combine ISNA and IF functions ottodesque Excel Worksheet Functions 8 August 25th 09 09:01 AM
Combine text functions Kay Excel Discussion (Misc queries) 2 July 13th 09 06:17 PM
How to combine, IF, AND, OR Functions Simony32567 Excel Worksheet Functions 2 May 18th 09 07:31 PM
Possible to combine VLOOKUP and IF(AND) functions? Ihoris Excel Worksheet Functions 1 April 6th 06 09:54 AM
Combine functions? ~suky~ Excel Worksheet Functions 0 February 23rd 06 03:51 PM


All times are GMT +1. The time now is 07:34 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"