Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3
Default IF and VLOOKUP - how efficient?

Hi I have a big dataset and each item needs to be classified as either
"active" or "inactive". By default lines are inactive, unless they are
contained within a subset that is listed in a separate database, where
individual lines are classified active/inactive, in which case they are
classifed the same as the separate database.

I'm currently using the following formula in my classification column:

IF(ISNA(VLOOKUP(A1,[Active
Analysis]Data!A:Z,26,FALSE)),"Inactive",VLOOKUP(A1,[Active
Analysis]Data!A:Z,26,FALSE))

My question is, when I use this formula does Excel execute the same lookup
twice, or is it smart enough to do the lookup once and use the result twice?
Either way it certainly seems to take a long time. Is there a more
efficient method?

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 10,593
Default IF and VLOOKUP - how efficient?

Yes it will if it is found. Put the VLOOKUP formula in another cell then
test

=IF(ISNA(cell_ref),"Inactive",cell_ref)

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



"anthonyg" wrote in message
...
Hi I have a big dataset and each item needs to be classified as either
"active" or "inactive". By default lines are inactive, unless they are
contained within a subset that is listed in a separate database, where
individual lines are classified active/inactive, in which case they are
classifed the same as the separate database.

I'm currently using the following formula in my classification column:

IF(ISNA(VLOOKUP(A1,[Active
Analysis]Data!A:Z,26,FALSE)),"Inactive",VLOOKUP(A1,[Active
Analysis]Data!A:Z,26,FALSE))

My question is, when I use this formula does Excel execute the same lookup
twice, or is it smart enough to do the lookup once and use the result
twice?
Either way it certainly seems to take a long time. Is there a more
efficient method?

Thanks



  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2,574
Default IF and VLOOKUP - how efficient?

It executes it twice. XL 2007 has the IFERROR function which has the format
=IFERROR(VLOOKUP(....),[else]) which is more efficient.

Dave
--
A hint to posters: Specific, detailed questions are more likely to be
answered than questions that provide no detail about your problem.


"anthonyg" wrote:

Hi I have a big dataset and each item needs to be classified as either
"active" or "inactive". By default lines are inactive, unless they are
contained within a subset that is listed in a separate database, where
individual lines are classified active/inactive, in which case they are
classifed the same as the separate database.

I'm currently using the following formula in my classification column:

IF(ISNA(VLOOKUP(A1,[Active
Analysis]Data!A:Z,26,FALSE)),"Inactive",VLOOKUP(A1,[Active
Analysis]Data!A:Z,26,FALSE))

My question is, when I use this formula does Excel execute the same lookup
twice, or is it smart enough to do the lookup once and use the result twice?
Either way it certainly seems to take a long time. Is there a more
efficient method?

Thanks

  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3,440
Default IF and VLOOKUP - how efficient?

If the item is not in the list, it will execute the VLOOKUP once, otherwise it will execute it twice.
You could place the VLOOKUP in a separate cell (column) and test that; that would certainly speed things up, but no more that
twice.
If you would be able to sort the range in which you look up, you could improve speed significantly by omitting the 4th argument of
VLOOKUP. In that case you would have to test for presence of the item yourself, but for large ranges it might well be hundreds of
times faster.
See:
http://www.decisionmodels.com/optspeede.htm

--
Kind regards,

Niek Otten
Microsoft MVP - Excel

"anthonyg" wrote in message ...
| Hi I have a big dataset and each item needs to be classified as either
| "active" or "inactive". By default lines are inactive, unless they are
| contained within a subset that is listed in a separate database, where
| individual lines are classified active/inactive, in which case they are
| classifed the same as the separate database.
|
| I'm currently using the following formula in my classification column:
|
| IF(ISNA(VLOOKUP(A1,[Active
| Analysis]Data!A:Z,26,FALSE)),"Inactive",VLOOKUP(A1,[Active
| Analysis]Data!A:Z,26,FALSE))
|
| My question is, when I use this formula does Excel execute the same lookup
| twice, or is it smart enough to do the lookup once and use the result twice?
| Either way it certainly seems to take a long time. Is there a more
| efficient method?
|
| Thanks


  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 15,768
Default IF and VLOOKUP - how efficient?

Another way:

Instead of duplicating the lookup and testing for an error, test to see if
the value is present:

=IF(COUNTIF(Data!A:A,A1),VLOOKUP(A1,Data!A:Z,26,0) ,"Inactive")

Biff

"anthonyg" wrote in message
...
Hi I have a big dataset and each item needs to be classified as either
"active" or "inactive". By default lines are inactive, unless they are
contained within a subset that is listed in a separate database, where
individual lines are classified active/inactive, in which case they are
classifed the same as the separate database.

I'm currently using the following formula in my classification column:

IF(ISNA(VLOOKUP(A1,[Active
Analysis]Data!A:Z,26,FALSE)),"Inactive",VLOOKUP(A1,[Active
Analysis]Data!A:Z,26,FALSE))

My question is, when I use this formula does Excel execute the same lookup
twice, or is it smart enough to do the lookup once and use the result
twice?
Either way it certainly seems to take a long time. Is there a more
efficient method?

Thanks





  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3
Default IF and VLOOKUP - how efficient?

Thanks for all the replies and the link to decision models. I followed the
instructions there and it is much faster now.

Thanks again.


"Niek Otten" wrote:

If the item is not in the list, it will execute the VLOOKUP once, otherwise it will execute it twice.
You could place the VLOOKUP in a separate cell (column) and test that; that would certainly speed things up, but no more that
twice.
If you would be able to sort the range in which you look up, you could improve speed significantly by omitting the 4th argument of
VLOOKUP. In that case you would have to test for presence of the item yourself, but for large ranges it might well be hundreds of
times faster.
See:
http://www.decisionmodels.com/optspeede.htm

--
Kind regards,

Niek Otten
Microsoft MVP - Excel

"anthonyg" wrote in message ...
| Hi I have a big dataset and each item needs to be classified as either
| "active" or "inactive". By default lines are inactive, unless they are
| contained within a subset that is listed in a separate database, where
| individual lines are classified active/inactive, in which case they are
| classifed the same as the separate database.
|
| I'm currently using the following formula in my classification column:
|
| IF(ISNA(VLOOKUP(A1,[Active
| Analysis]Data!A:Z,26,FALSE)),"Inactive",VLOOKUP(A1,[Active
| Analysis]Data!A:Z,26,FALSE))
|
| My question is, when I use this formula does Excel execute the same lookup
| twice, or is it smart enough to do the lookup once and use the result twice?
| Either way it certainly seems to take a long time. Is there a more
| efficient method?
|
| Thanks



  #7   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 52
Default IF and VLOOKUP - how efficient?

IsNumber/Match is faster than CountIf though.

T. Valko wrote:
Another way:

Instead of duplicating the lookup and testing for an error, test to see if
the value is present:

=IF(COUNTIF(Data!A:A,A1),VLOOKUP(A1,Data!A:Z,26,0) ,"Inactive")

Biff

"anthonyg" wrote in message
...
Hi I have a big dataset and each item needs to be classified as either
"active" or "inactive". By default lines are inactive, unless they are
contained within a subset that is listed in a separate database, where
individual lines are classified active/inactive, in which case they are
classifed the same as the separate database.

I'm currently using the following formula in my classification column:

IF(ISNA(VLOOKUP(A1,[Active
Analysis]Data!A:Z,26,FALSE)),"Inactive",VLOOKUP(A1,[Active
Analysis]Data!A:Z,26,FALSE))

My question is, when I use this formula does Excel execute the same lookup
twice, or is it smart enough to do the lookup once and use the result
twice?
Either way it certainly seems to take a long time. Is there a more
efficient method?

Thanks



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
What is more efficient Brad Excel Discussion (Misc queries) 2 November 20th 06 09:13 PM
more efficient way to lookup a range? [email protected] Excel Discussion (Misc queries) 1 May 12th 06 05:41 AM
something more efficient that =IF, and sytax questions mcrae Excel Discussion (Misc queries) 2 April 1st 06 07:10 AM
how to plot efficient frontier Sandy Excel Discussion (Misc queries) 0 April 17th 05 02:26 AM
is there a more efficient formula than... Wazooli Excel Worksheet Functions 6 February 24th 05 06:39 PM


All times are GMT +1. The time now is 10:32 PM.

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

About Us

"It's about Microsoft Excel"