Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
Comparing An Array in VBA
To all those VBA experts out there, I've written a simple macro in
VBA. The purpose is to alert the user if they encounter a value that isn't currently in an array. They way I did this is that I compared the value to each piece of the array within a nested loop. Is there a way to determine if the value is in the array without having to compare each piece of the array. If so, what's the function. Thanks in advance for any help. Greg |
#2
Posted to microsoft.public.excel.misc
|
|||
|
|||
Comparing An Array in VBA
Does upper/lower case matter?
If no: dim myArr as Variant dim myVal as Variant dim res as variant myarr = array("a","b","xyz",1,3,6) myval = "xyz" 'or whatever res = application.match(myval,myarr,0) if isnumber(res) then msgbox "It's in the array else msgbox "it's not" end if Greg wrote: To all those VBA experts out there, I've written a simple macro in VBA. The purpose is to alert the user if they encounter a value that isn't currently in an array. They way I did this is that I compared the value to each piece of the array within a nested loop. Is there a way to determine if the value is in the array without having to compare each piece of the array. If so, what's the function. Thanks in advance for any help. Greg -- Dave Peterson |
#3
Posted to microsoft.public.excel.misc
|
|||
|
|||
Comparing An Array in VBA
Dave,
Thanks. That woked, although I had to replace isnumber with isnumeric. Greg |
#4
Posted to microsoft.public.excel.misc
|
|||
|
|||
Comparing An Array in VBA
Oops. Sorry.
Glad you got it working! Greg wrote: Dave, Thanks. That woked, although I had to replace isnumber with isnumeric. Greg -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Positioning Numeric Values Resulting from 6 Column Array Formula | Excel Worksheet Functions | |||
Return Array with Array | Excel Worksheet Functions | |||
return array result in cell based on comparing dates | Excel Worksheet Functions | |||
Formula to list unique values | Excel Worksheet Functions | |||
VBA Import of text file & Array parsing of that data | Excel Discussion (Misc queries) |