Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
Finding the Location within an Array
Hi All,
Thanks to this Group I was provided a snipit of code to find out is a value is within my Array:- If Not IsError(Application.Match(some_value, myArray,0)) Then Do somthing else Do somthing else End If This works Great Thank You. Is it possible to find out the location of the value without having to loop through each entry? Many Thanks Mark |
#2
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
Finding the Location within an Array
dim res as variant
res = application.match(some_value, myArray,0) if iserror(res) then 'no match else msgbox res end if Sh0t2bts wrote: Hi All, Thanks to this Group I was provided a snipit of code to find out is a value is within my Array:- If Not IsError(Application.Match(some_value, myArray,0)) Then Do somthing else Do somthing else End If This works Great Thank You. Is it possible to find out the location of the value without having to loop through each entry? Many Thanks Mark -- Dave Peterson |
#3
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
Finding the Location within an Array
On Wed, 5 Dec 2007 03:45:33 -0800 (PST), Sh0t2bts wrote:
Hi All, Thanks to this Group I was provided a snipit of code to find out is a value is within my Array:- If Not IsError(Application.Match(some_value, myArray,0)) Then Do somthing else Do somthing else End If This works Great Thank You. Is it possible to find out the location of the value without having to loop through each entry? Many Thanks Mark You merely return the result of your Match function. ===================================== Option Explicit Sub foo() Dim bar As Variant Dim foobar bar = Array(1, 5, 10, 15, 20) foobar = 10 Debug.Print "Value foobar", foobar, "Location " & _ Application.WorksheetFunction.Match(foobar, bar, 0) End Sub ============================== Note that MATCH will return a 1's based count. So if your array is 0 based, then the "location" within the array will be offset by 1. --ron |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Finding the location of what was summed | Excel Worksheet Functions | |||
Finding the location of MAX value in column | Excel Discussion (Misc queries) | |||
Finding Location of Maximum Value in 2D Array | Excel Discussion (Misc queries) | |||
Finding Location of Maximum Value in 2D Array | New Users to Excel | |||
Finding Location of Maximum Value in 2D Array | Excel Worksheet Functions |