Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Bob Bob is offline
external usenet poster
 
Posts: 972
Default Using MATCH function in VBA

I'm getting an "Unable to get the Match property of the WorksheetFunction
class" error message when the "i = WorksheetFunction.Match(..." line of code
is executed in the following code block:

Dim i As Integer
Dim SysRCNameTemp As String
Dim SysRCNameArray(25) As String

i = Application.WorksheetFunction.Match(SysRCNameTemp, _
SysRCNameArray(), 0)

Can someone tell me how to fix the aforementioned line of code? Thanks in
advance for any help.

  #2   Report Post  
Posted to microsoft.public.excel.programming
JMB JMB is offline
external usenet poster
 
Posts: 2,062
Default Using MATCH function in VBA

I get that error with your code when the array does not contain the value you
are trying to match. This seems to work fine, though:

i = Application.Match(SysRCNameTemp, SysRCNameArray, 0)

With i dimmed as int, you will still get a type mismatch error if match
returns an error. You might consider dimming i as a variant (you could use
isnumeric to test it and see if match returned an error or a number).


"Bob" wrote:

I'm getting an "Unable to get the Match property of the WorksheetFunction
class" error message when the "i = WorksheetFunction.Match(..." line of code
is executed in the following code block:

Dim i As Integer
Dim SysRCNameTemp As String
Dim SysRCNameArray(25) As String

i = Application.WorksheetFunction.Match(SysRCNameTemp, _
SysRCNameArray(), 0)

Can someone tell me how to fix the aforementioned line of code? Thanks in
advance for any help.

  #3   Report Post  
Posted to microsoft.public.excel.programming
Bob Bob is offline
external usenet poster
 
Posts: 972
Default Using MATCH function in VBA

Thanks for the suggestion! Dimensioning "i" as a Variant and using the
IsNumeric function to trap for a number or error did the trick!


"JMB" wrote:

I get that error with your code when the array does not contain the value you
are trying to match. This seems to work fine, though:

i = Application.Match(SysRCNameTemp, SysRCNameArray, 0)

With i dimmed as int, you will still get a type mismatch error if match
returns an error. You might consider dimming i as a variant (you could use
isnumeric to test it and see if match returned an error or a number).


"Bob" wrote:

I'm getting an "Unable to get the Match property of the WorksheetFunction
class" error message when the "i = WorksheetFunction.Match(..." line of code
is executed in the following code block:

Dim i As Integer
Dim SysRCNameTemp As String
Dim SysRCNameArray(25) As String

i = Application.WorksheetFunction.Match(SysRCNameTemp, _
SysRCNameArray(), 0)

Can someone tell me how to fix the aforementioned line of code? Thanks in
advance for any help.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default Using MATCH function in VBA

Thank you both for your short but accurate exchange. You helped me too.
--
TomThumb


"Bob" wrote:

Thanks for the suggestion! Dimensioning "i" as a Variant and using the
IsNumeric function to trap for a number or error did the trick!


"JMB" wrote:

I get that error with your code when the array does not contain the value you
are trying to match. This seems to work fine, though:

i = Application.Match(SysRCNameTemp, SysRCNameArray, 0)

With i dimmed as int, you will still get a type mismatch error if match
returns an error. You might consider dimming i as a variant (you could use
isnumeric to test it and see if match returned an error or a number).


"Bob" wrote:

I'm getting an "Unable to get the Match property of the WorksheetFunction
class" error message when the "i = WorksheetFunction.Match(..." line of code
is executed in the following code block:

Dim i As Integer
Dim SysRCNameTemp As String
Dim SysRCNameArray(25) As String

i = Application.WorksheetFunction.Match(SysRCNameTemp, _
SysRCNameArray(), 0)

Can someone tell me how to fix the aforementioned line of code? Thanks in
advance for any help.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Using MATCH function in VBA

If I have a Match function like
Match(1,(range_name1=variable_name1)*(range_name2= variable_name2),0)
will you please tell me how I should rewrite the code given by you ?
range_name1 has text, range_name2 has numbers.


--
esbee


"JMB" wrote:

I get that error with your code when the array does not contain the value you
are trying to match. This seems to work fine, though:

i = Application.Match(SysRCNameTemp, SysRCNameArray, 0)

With i dimmed as int, you will still get a type mismatch error if match
returns an error. You might consider dimming i as a variant (you could use
isnumeric to test it and see if match returned an error or a number).


"Bob" wrote:

I'm getting an "Unable to get the Match property of the WorksheetFunction
class" error message when the "i = WorksheetFunction.Match(..." line of code
is executed in the following code block:

Dim i As Integer
Dim SysRCNameTemp As String
Dim SysRCNameArray(25) As String

i = Application.WorksheetFunction.Match(SysRCNameTemp, _
SysRCNameArray(), 0)

Can someone tell me how to fix the aforementioned line of code? Thanks in
advance for any help.



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
find the second match using the match function Ray Excel Worksheet Functions 1 April 6th 09 10:19 PM
how can we get unique values in match function for same match key. Xcel[_2_] Excel Worksheet Functions 11 December 7th 07 08:13 PM
index match array function-returning only first match, need last. Julie Olsen Excel Worksheet Functions 3 December 29th 06 12:50 AM
Match as well as does not match array function Vikram Dhemare Excel Discussion (Misc queries) 7 April 25th 06 09:15 AM
Offset function with nested match function not finding host ss. MKunert Excel Worksheet Functions 1 March 21st 06 10:46 PM


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