LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 97
Default Is there a way of asking "is a member of" in VBA?

I often have to test whether any of a range of numbers (x in the example
below) is represented in a set of values - which may or may not be entered
in a range of cells. If I put the set of values into an array (ArrValues
below - could be one- or two-dimensional), is there a neat way of asking:

If x "is a member of" ArrValues

on one line of code, or do I have to cycle through all the members of
ArrValues in turn (say using For loop) and check whether each one is equal
to x? I've tried using the Match WorksheetFunction with 0 as the third
argument:


With WorksheetFunction
For x = 1 To 100
If Not .IsNA(.Match(x, ArrValues, 0)) Then
Cells(x, 14) = x 'report matching values in column 14
End If
Next k
End With

but it doesn't work - I get an "Unable to get the Match property of the
WorksheetFunction class".

Instead, I'm having to do this, for example:

For i = 1 To 10
For j = 1 To 10
For x = 1 To 100
If ArrValues(i, j) = x Then
Cells(x, 14) = x 'report values in column 14
End If
Next k
Next j
Next i

The example may seem trivial, but I have other instances where it's not so
trivial.

Thanks

Ian


 
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
"Member not found" exception...Help! Nick Chadwick[_2_] Excel Programming 0 July 25th 04 03:19 PM
Getting "compile error" "method or data member not found" on reinstall Bp Excel Programming 1 April 23rd 04 04:42 PM
"Member Not Found" Error with Excel 2000 Paul Excel Programming 2 August 14th 03 03:22 PM


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