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

Hi,

I have some dates in column E (starting from 31-Jan-2005 to 31-Oct-09
-- 3 Month stretch)

If I put the following formula in my excel worksheet

=MATCH(TODAY()-1,$E$2:$E$21,1)

then I get the correct value as 6.

But If I write in VBA

RowNoForReportRange = Application.WorksheetFunction.Match(Date - 1,
TargetWkbook.Worksheets(LegendSt).Range("$E$2:$E$2 1").Value, 1)

Then the answer I get is 15. Am not able to figure out why?

Could somebody please guide me.

Regards,
HP
India

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 46
Default Match in VBA

Don,

I actually want to find the largest date which is smaller (or equal)
than Today - 1. Hence, I have been using the argument 1.

If I use this formula in my spreadsheet it gives correct values as 6,
but If I use it within VBA it is giving as 14. Am not able to figure
out as to why this is happening.

regards,
HP
India

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 46
Default Match in VBA


Hari wrote:
Don,

I actually want to find the largest date which is smaller (or equal)
than Today - 1. Hence, I have been using the argument 1.

If I use this formula in my spreadsheet it gives correct values as 6,
but If I use it within VBA it is giving as 14. Am not able to figure
out as to why this is happening.


Could somebody take a guess as to what might be wrong in my VBA
statement

regards,
HP
India

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default Match in VBA

Hari,
Try it without ".Value"
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 46
Default Match in VBA


Jim Cone wrote:
Hari,
Try it without ".Value"
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware


Without . Value, the error I get is

Run time error '1004':
Unable to get the match property of the worksheet function class

Not sure as to why this is happenning.

Regards,
HP
India

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
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
index match array function-returning only first match, need last. Julie Olsen Excel Worksheet Functions 3 December 29th 06 12:50 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 03:15 AM.

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"