Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
mbrockhaus
 
Posts: n/a
Default Can I use "In" in an "If" statement?

I want to determine if a value in column A is in a list of values, using an
if statement. Do I need to list each condition separately? For example, is
there a better way to write the following statement?

=IF(OR($A2<"Benchmark",$A2<"Benchmark Folder",$A2<"Physical
Name",$A2="Label Part"), "y", "n")
  #2   Report Post  
Posted to microsoft.public.excel.misc
Bearacade
 
Posts: n/a
Default Can I use "In" in an "If" statement?


You can save 4 characters by doing this...

=IF(OR($A2="benchmark",$A2="benchmark folder",$A2="physical
name",$A2="label part"), "n", "y")

it doesn't check for case, so you don't have to cap the first
letter...

The other thing you can do is make a table of what you are checking, I
put it in L1:L4

=IF(ISERROR(MATCH(A2,L1:L4)), "y", "n")


--
Bearacade


------------------------------------------------------------------------
Bearacade's Profile: http://www.excelforum.com/member.php...o&userid=35016
View this thread: http://www.excelforum.com/showthread...hreadid=557100

  #3   Report Post  
Posted to microsoft.public.excel.misc
Dave Peterson
 
Posts: n/a
Default Can I use "In" in an "If" statement?

I would think you'd want an exact match:
=IF(ISERROR(MATCH(A2,L1:L4,0)), "y", "n")

or alternatively:
=IF(ISnumber(MATCH(A2,L1:L4,0)), "n", "y")




Bearacade wrote:

You can save 4 characters by doing this...

=IF(OR($A2="benchmark",$A2="benchmark folder",$A2="physical
name",$A2="label part"), "n", "y")

it doesn't check for case, so you don't have to cap the first
letter...

The other thing you can do is make a table of what you are checking, I
put it in L1:L4

=IF(ISERROR(MATCH(A2,L1:L4)), "y", "n")

--
Bearacade

------------------------------------------------------------------------
Bearacade's Profile: http://www.excelforum.com/member.php...o&userid=35016
View this thread: http://www.excelforum.com/showthread...hreadid=557100


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.misc
Bearacade
 
Posts: n/a
Default Can I use "In" in an "If" statement?


Aye, true, thanks Dave


--
Bearacade


------------------------------------------------------------------------
Bearacade's Profile: http://www.excelforum.com/member.php...o&userid=35016
View this thread: http://www.excelforum.com/showthread...hreadid=557100

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
Copy an "if" Statement sgausti Excel Discussion (Misc queries) 4 June 27th 06 07:36 PM
An "If" statement coded in a macro rojobrown Excel Worksheet Functions 2 April 12th 06 07:57 PM
"IF" statement & "strikethrough" formatting jijy Excel Worksheet Functions 3 March 22nd 06 06:56 PM
"If" statement using "And" Amanda Excel Discussion (Misc queries) 2 December 28th 05 03:02 PM
The "IF" Statement JeremyH1982 Excel Worksheet Functions 1 October 18th 05 08:32 PM


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