Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default If Range("C1") is in MyArray

Being very unfamiliar with arrays, but impressed with their worth, I am
trying to code with an array. I have defined MyArray, and now want to check
to see if the cell value in "C1" is the same as any of my array values. How
do I code that?

Say: MyArray("one", "two", "three", "four", "five", "six", "seven",
"eight")
If Range("C1").value = [...is in MyArray] then
(do something)
End

How do I test for C1's value being in MyArray? (Sorry if this is unclear; I
am very trying...)

TIA


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 226
Default If Range("C1") is in MyArray

My usual approach is

If IsNumeric(Application.Match(Range("C1").Value, MyArray, 0)) Then
'Is in the array
End If

--
Regards,

Juan Pablo González

"zSplash" <zNOSPAMSplash@ gci.net wrote in message
...
Being very unfamiliar with arrays, but impressed with their worth, I am
trying to code with an array. I have defined MyArray, and now want to

check
to see if the cell value in "C1" is the same as any of my array values.

How
do I code that?

Say: MyArray("one", "two", "three", "four", "five", "six", "seven",
"eight")
If Range("C1").value = [...is in MyArray] then
(do something)
End

How do I test for C1's value being in MyArray? (Sorry if this is unclear;

I
am very trying...)

TIA




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default If Range("C1") is in MyArray

Thanks, Juan, for your help.

I'm too ignorant to use your method, but will try it when I understand it.

The following code seemed to "work" for me:
For H = 1 To 12
If Range("F" & N) = MyArray(H) Then
(do something)
End If
Next

st.

"Juan Pablo Gonzalez" wrote in message
...
My usual approach is

If IsNumeric(Application.Match(Range("C1").Value, MyArray, 0)) Then
'Is in the array
End If

--
Regards,

Juan Pablo González

"zSplash" <zNOSPAMSplash@ gci.net wrote in message
...
Being very unfamiliar with arrays, but impressed with their worth, I am
trying to code with an array. I have defined MyArray, and now want to

check
to see if the cell value in "C1" is the same as any of my array values.

How
do I code that?

Say: MyArray("one", "two", "three", "four", "five", "six", "seven",
"eight")
If Range("C1").value = [...is in MyArray] then
(do something)
End

How do I test for C1's value being in MyArray? (Sorry if this is

unclear;
I
am very trying...)

TIA






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 226
Default If Range("C1") is in MyArray

My method works by using the MATCH() worksheet function. Basically, in
Excel you would use it like

=MATCH(C1, A1:A100, 0)

to look for the value of C1 in the array A1:A100, using an exact match (0 as
the third parameter)

If the value is found, MATCH() returns a number (the position of C1 inside
the array), else, it return #N/A. So, what the code does is check the
result of MATCH(), if its a number, then your value is in the array, if not,
then it will return an error, which means that it's not in it.

--
Regards,

Juan Pablo González

"zSplash" <zNOSPAMSplash@ gci.net wrote in message
...
Thanks, Juan, for your help.

I'm too ignorant to use your method, but will try it when I understand it.

The following code seemed to "work" for me:
For H = 1 To 12
If Range("F" & N) = MyArray(H) Then
(do something)
End If
Next

st.

"Juan Pablo Gonzalez" wrote in message
...
My usual approach is

If IsNumeric(Application.Match(Range("C1").Value, MyArray, 0)) Then
'Is in the array
End If

--
Regards,

Juan Pablo González

"zSplash" <zNOSPAMSplash@ gci.net wrote in message
...
Being very unfamiliar with arrays, but impressed with their worth, I

am
trying to code with an array. I have defined MyArray, and now want to

check
to see if the cell value in "C1" is the same as any of my array

values.
How
do I code that?

Say: MyArray("one", "two", "three", "four", "five", "six", "seven",
"eight")
If Range("C1").value = [...is in MyArray] then
(do something)
End

How do I test for C1's value being in MyArray? (Sorry if this is

unclear;
I
am very trying...)

TIA








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
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
change "true" and "false" to "availble" and "out of stock" inthestands Excel Worksheet Functions 2 July 19th 07 07:05 PM
HELP on "left","right","find","len","substitute" functions serene83 Excel Discussion (Misc queries) 5 June 27th 06 02:23 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


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