Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 103
Default match in vba

greetings, am using Application.WorksheetFunction.Match, using 0 - for exact
match, comparing two ranges (one in sheet1, other sheet2). i want to
highlight the columns of range in sheet2 which are not included in range in
sheet1. running into problem, i think, because when there is column which is
not in sheet1 range the function returns value equivalent to "N/A". have
tried using:

Application.WorksheetFucntion.IsNA(WorksheetFuncti on.Match()) but can't get
this to work. any and all suggestions appreciated, thanks!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default match in vba

First, you'd have to spell .worksheetfunction correct to even get close!

But I'd drop the .worksheetfunction completely.

dim res as variant
.....

res = application.match(someval, somerng, 0)
if iserror(res) then
'not found
else
'is found
end if

There's a difference between the way VBA uses application.match() and
application.worksheetfunction.match().

The first returns an error you can check with iserror().

The second causes a runtime error that you have to code around.

dim res as variant
....
on error resume next
res = application.worksheetfunction.match(...)
if err.number < 0 then
'no match
err.clear
else
'found a match
end if
on error goto 0

I find using application.match() easier.


mwam423 wrote:

greetings, am using Application.WorksheetFunction.Match, using 0 - for exact
match, comparing two ranges (one in sheet1, other sheet2). i want to
highlight the columns of range in sheet2 which are not included in range in
sheet1. running into problem, i think, because when there is column which is
not in sheet1 range the function returns value equivalent to "N/A". have
tried using:

Application.WorksheetFucntion.IsNA(WorksheetFuncti on.Match()) but can't get
this to work. any and all suggestions appreciated, thanks!


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default match in vba

Ps. The same distinction happens with application.vlookup() and
application.worksheetfunction.vlookup().



mwam423 wrote:

greetings, am using Application.WorksheetFunction.Match, using 0 - for exact
match, comparing two ranges (one in sheet1, other sheet2). i want to
highlight the columns of range in sheet2 which are not included in range in
sheet1. running into problem, i think, because when there is column which is
not in sheet1 range the function returns value equivalent to "N/A". have
tried using:

Application.WorksheetFucntion.IsNA(WorksheetFuncti on.Match()) but can't get
this to work. any and all suggestions appreciated, thanks!


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 103
Default match in vba


hi dave, that did the trick, thanks much. this might be really simple
question but, why the subtle difference between Application.Match and
Application.WorksheetFunction.Match? not complaining, after all difference
allowed for fix to problem, just curious.

oh, regarding spelling, i consider two outta three pretty good =D

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default match in vba

I have no idea why there's a difference--just that there is.

And that's pretty good, too <vbg.

mwam423 wrote:

hi dave, that did the trick, thanks much. this might be really simple
question but, why the subtle difference between Application.Match and
Application.WorksheetFunction.Match? not complaining, after all difference
allowed for fix to problem, just curious.

oh, regarding spelling, i consider two outta three pretty good =D


--

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 formula to match values in multiple columns K[_2_] Excel Discussion (Misc queries) 2 April 22nd 10 10:22 AM
Lookup Formula: Return 1st match, then 2nd match, then 3rd match Scott Excel Discussion (Misc queries) 4 December 11th 09 05:50 AM
index(match) Wind Uplift Calculations (match four conditions) JMeier Excel Worksheet Functions 8 August 1st 08 01:45 AM
MATCH Multiple Criteria & Return Previous / Penultimate Match Sam via OfficeKB.com Excel Worksheet Functions 27 October 6th 07 01:39 AM
Lookup? Match? pulling rows from one spreadsheet to match a text f cjax Excel Worksheet Functions 3 July 21st 06 02:51 PM


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