Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Using the "IN" function in Excel

I'm trying to evaluate if a cell value resides in a list
of values. I'm trying to use the IN function similar to
how I use it in Access but it keeps erroring out. Can
anyone help me understand what I'm doing wrong? Here is
the sample code I'm using. Many Thanks!

If Cells(1, b).value in
("0309","0713","0728","0730","0741","1020","1022") , then
MsgBox "test"
End If
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default Using the "IN" function in Excel

Chilidog,

I've never seen the syntax you used i.e. "IN". The following will check if
the string exists-

Dim sTest As String
sTest = Cells(1, 2).Value
sTest = Application.Rept("0", 4 - Len(sTest)) & sTest & " "
If InStr("0309 0713 0728 0730 0741 1020 1022 ", sTest) 0 Then
MsgBox "test"
End If

regards,

JohnI

"Chilidog1000" wrote in message
...
I'm trying to evaluate if a cell value resides in a list
of values. I'm trying to use the IN function similar to
how I use it in Access but it keeps erroring out. Can
anyone help me understand what I'm doing wrong? Here is
the sample code I'm using. Many Thanks!

If Cells(1, b).value in
("0309","0713","0728","0730","0741","1020","1022") , then
MsgBox "test"
End If



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Using the "IN" function in Excel

Try this:

Select Case Cells(1, "B").Value
Case "0309", "0713", "0728", "0730", "0741", "1020", "1022"
MsgBox "test"
End Select

hth,

Doug


"Chilidog1000" wrote in message
...
I'm trying to evaluate if a cell value resides in a list
of values. I'm trying to use the IN function similar to
how I use it in Access but it keeps erroring out. Can
anyone help me understand what I'm doing wrong? Here is
the sample code I'm using. Many Thanks!

If Cells(1, b).value in
("0309","0713","0728","0730","0741","1020","1022") , then
MsgBox "test"
End If



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 459
Default Using the "IN" function in Excel

I've never seen the syntax you used i.e. "IN".

I have, in SQL e.g.

SELECT RefID FROM MyTable WHERE RefID IN (1,3,8,21,55)

"JohnI in Brisbane" wrote in message ...
Chilidog,

I've never seen the syntax you used i.e. "IN". The following will check if
the string exists-

Dim sTest As String
sTest = Cells(1, 2).Value
sTest = Application.Rept("0", 4 - Len(sTest)) & sTest & " "
If InStr("0309 0713 0728 0730 0741 1020 1022 ", sTest) 0 Then
MsgBox "test"
End If

regards,

JohnI

"Chilidog1000" wrote in message
...
I'm trying to evaluate if a cell value resides in a list
of values. I'm trying to use the IN function similar to
how I use it in Access but it keeps erroring out. Can
anyone help me understand what I'm doing wrong? Here is
the sample code I'm using. Many Thanks!

If Cells(1, b).value in
("0309","0713","0728","0730","0741","1020","1022") , then
MsgBox "test"
End If

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 "comparison" operator for "contains" used in an "IF" Function Pawaso Excel Worksheet Functions 4 April 4th 23 11:35 AM
Excel 2003: Conditional Formatting using "MIN" & "MAX" function MMangen Excel Discussion (Misc queries) 2 September 16th 08 07:13 PM
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
Count occurences of "1"/"0" (or"TRUE"/"FALSE") in a row w. conditions in the next BCB New Users to Excel 7 May 13th 06 10:02 PM
inserting a conditional "go to" command on a excel "if" function velasques Excel Worksheet Functions 5 March 10th 06 08:16 PM


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