Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default return value from MATCH

I'm trying to get the value returned from the following MATCH

=MATCH("some name",sheet1!A1:A450,0)

it will return the row number that the match occured in.
this is the value I need.
I need to retrieve it from a macro.

I can;t seem to figure out the syntax to get that value.

if I simply use in a worksheet ...the formula will return what I need
but and dump in the current cell. I don't want to dump the result in a
cell but simply in my variable frommy macro..
how would I go about this?

thanks

PAbs


---
Message posted from http://www.ExcelForum.com/

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default return value from MATCH

dim res as variant

res = application.match("some name", worksheets("sheet1").range("a1:a450"),0)

if iserror(res) then
msgbox "no match!"
else
msgbox worksheets("sheet1").range("a1:a450")(res) & _
" is " & res & " rows into the table"
end if

"pabs <" wrote:

I'm trying to get the value returned from the following MATCH

=MATCH("some name",sheet1!A1:A450,0)

it will return the row number that the match occured in.
this is the value I need.
I need to retrieve it from a macro.

I can;t seem to figure out the syntax to get that value.

if I simply use in a worksheet ...the formula will return what I need
but and dump in the current cell. I don't want to dump the result in a
cell but simply in my variable frommy macro..
how would I go about this?

thanks

PAbs

---
Message posted from http://www.ExcelForum.com/


--

Dave Peterson

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default return value from MATCH

that seems to works...
but how do I get the integer value form it,,
I need to pass that value as an integer to my other routine.

if I try to pass my variant "res" it gives me a "type mismatch"
error..

:(


---
Message posted from http://www.ExcelForum.com/

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 100
Default return value from MATCH

Pab

Are you trying to pass res or "res". If the latter, then you will not get the contents of the variable (ie the value of the match), but the alpha string res

Tony
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 55
Default return value from MATCH


-----Original Message-----
if I try to pass my variant "res"
it gives me a "type mismatch"
error..


Try putting it in brackets -
that will transfer the value only, e.g.

Dim res as Variant, myVariable as Long

res = "1234"
myVariable = (res) + 46

RClay AT haswell DOT com


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default return value from MATCH

actually, that works...gettting the value in res.

my problem is that I need to refer to another file.

if you look at the formula it specifies a particular workbook
(sheet1)

res = application.match("some name", worksheets("*sheet1
").range("a1:a450"),0)


I also need to specify from what file it's in (since I have more tha
one file open at once)

I tried [fileName.xls]Sheet1 but that didn't work when I tried it...

not sure on what the syntax would have to be..

--
Message posted from http://www.ExcelForum.com

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default return value from MATCH

What part are you specifying?

maybe replace
worksheets("sheet1").range("a1:a450")
with
workbooks("filename.xls").worksheets("sheet975").r ange("a1:a450")



"pabs <" wrote:

actually, that works...gettting the value in res.

my problem is that I need to refer to another file.

if you look at the formula it specifies a particular workbook.
(sheet1)

res = application.match("some name", worksheets("*sheet1*
").range("a1:a450"),0)

I also need to specify from what file it's in (since I have more than
one file open at once)

I tried [fileName.xls]Sheet1 but that didn't work when I tried it...

not sure on what the syntax would have to be...

---
Message posted from http://www.ExcelForum.com/


--

Dave Peterson

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
Match 2 Columns, Return 3rd, Differing Match Types Matt.Russett Excel Worksheet Functions 3 May 11th 10 10:45 AM
Lookup Formula: Return 1st match, then 2nd match, then 3rd match Scott Excel Discussion (Misc queries) 4 December 11th 09 05:50 AM
need to return next match of table, only finding first match...HEL nwtf_vol[_2_] Excel Worksheet Functions 0 January 23rd 08 01:42 AM
MATCH Multiple Criteria & Return Previous / Penultimate Match Sam via OfficeKB.com Excel Worksheet Functions 27 October 6th 07 01:39 AM
Compare Value in Cell 1 to a List, Return Value if Match otherwise Return Null Ben Excel Discussion (Misc queries) 2 March 15th 07 01:02 AM


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