Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 577
Default Need help using date as an index

I have 2 workbooks. The first workbook has names in column A and dates in
column B. The names can be repeated for different dates. The workbook is
sorted by column A then B. I have used the following to get the first date
for a given name

DBRowNumFirst = Application.Match(DBName, Range("A3:A2000"), 0)
DBDate = Range("B" + CStr(DBRowNumFirst)).Value

At the top of the workbook I have

Dim DBDate As Date

The second workbook has sorted dates in column A. I want to use DBDate to
find the matching or first date greater than DBDate in this second workbook.
I have tried this but I get an error 2042.

SWDate1 = Application.Match(DBDate, Range("A4:A2000"), 3)

I can use a loop to find what I am looking for but would like a simple
function call like match or find. Any ideas?


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 857
Default Need help using date as an index

Scott,

Try replacing this line:

DBDate = Range("B" + CStr(DBRowNumFirst)).Value

with this:

DBDate = Range("B" + CStr(DBRowNumFirst + 2)).Value

That is because you started the search on A3 and Match will return the
position of the value found..meaning if it returned a value of 1, then you
need to get the value in column B, row 3.

Next, try replacing this line:

SWDate1 = Application.Match(DBDate, Range("A4:A2000"), 3)

with this:

SWDate1 = Application.Match(CLng(DBDate), Range("A4:A2000"), 3)

date values in Excel are actually numbers (days passed since 1/0/1900).



--
Hope that helps.

Vergel Adriano


"Scott" wrote:

I have 2 workbooks. The first workbook has names in column A and dates in
column B. The names can be repeated for different dates. The workbook is
sorted by column A then B. I have used the following to get the first date
for a given name

DBRowNumFirst = Application.Match(DBName, Range("A3:A2000"), 0)
DBDate = Range("B" + CStr(DBRowNumFirst)).Value

At the top of the workbook I have

Dim DBDate As Date

The second workbook has sorted dates in column A. I want to use DBDate to
find the matching or first date greater than DBDate in this second workbook.
I have tried this but I get an error 2042.

SWDate1 = Application.Match(DBDate, Range("A4:A2000"), 3)

I can use a loop to find what I am looking for but would like a simple
function call like match or find. Any ideas?


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
VLOOKUP or MATCH and/or INDEX to extract value on a given date Don Kline[_2_] Excel Worksheet Functions 7 July 21st 09 02:25 PM
Four criteria MATCH INDEX lookup of date between matching two text John_J Excel Worksheet Functions 9 September 23rd 08 01:33 PM
VLOOKUP MATCH INDEX two conditions / criterias text and date John Excel Worksheet Functions 7 September 10th 08 11:31 AM
Question about using MIN/MAX, INDEX with Date range ML Srini Excel Worksheet Functions 3 October 4th 07 12:59 AM
How to sum up a Year-to-date figure by using INDEX et Excel Discussion (Misc queries) 2 February 21st 07 05:10 AM


All times are GMT +1. The time now is 03:45 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"