View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Jacob Skaria Jacob Skaria is offline
external usenet poster
 
Posts: 8,520
Default WorksheetFunction.Match


Try

Set StartDate = Worksheets("Data1").Range("Z" &
WorksheetFunction.Match(DateValue(TextBox1),
Worksheets("Data1").Range("Z3:Z600").Value, 0) + 2)

If this post helps click Yes
---------------
Jacob Skaria


"John P" wrote:

Hi. Can someone please pinpoint the error in this match function statement
using a textbox which contains the lookup date to match a column of dates in
column Z. Program works if I do not use the textbox otherwise it gives a
runtime error:

Set StartDate = Worksheets("Data1").Range("Z" &
WorksheetFunction.Match(DateValue(TextBox1.Value),
Worksheets("Data1").Range("Z3:Z600"), 0) + 2)

StartDate declared as a range object.
Dates are in 3/14/01 format.
Textbox1 contains a date
Column Z is a series of dates

When I replace the textbox with a cell to contain the lookup date, the rest
of the program works. So the error can be narrowed to this sub expression:
DateValue(TextBox1.Value)

Thanks for your advice.