View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Alan Beban Alan Beban is offline
external usenet poster
 
Posts: 200
Default Getting a the position of a single item in an array

Works fine in xl2002. There must be something odd about jdate.

Alan Beban

wrote:
On 23 Jul, 17:07, pinkfloydfan wrote:
Hi there

Using Excel 2003

In VBA I have a one-dimensional array of dates called dateslist() and
wish to test what position in this array a single date value (called
jdate) is at.

To do this I am using the following in my code:

datepos = Application.WorksheetFunction.Match(jdate, dateslist, 0)

BUT, it keeps returning an error "Run-time error 1004: Unable to get
the Match property of the WorksheetFunction class"

Anybody know how to fix this please? Or a better way to get the
answer I am seeking?

Many Thanks
Lloyd


Lloyd,

The only way that I know is to loop through the array to find the
value you are looking for

e.g. where option base is 0:

For i = 0 To UBound(datelist)
If datelist(i) = jdate Then datepos = i
Next i

hth

Toyin.