LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Match Date Search


Hi there, new to excel forum & also slow learner in VBA. Am doing a
match date search & then copying that range of price with the date
range to another worksheet. used this code as suggested but unable to
work, it end with a "Start date not found" msg.
My date is in column B formatted as dd/mm/yyyy. Have tried adding the
cdate to the startdate & enddate & also changing the 0 to 1 in the
match function, but still the same.
Any one can help, thanks greatly



Code:
--------------------
Option Explicit

Sub FindDates()
Worksheets("Prices").Select

On Error Goto errorHandler
Dim startDate As String
Dim stopDate As String
Dim startRow As Integer
Dim stopRow As Integer
Dim rng1 As Range, rng2 As Range
Dim x As Variant, r As Range

startDate = InputBox("Enter the Start Date: (dd/mm/yyyy)")
If startDate = "" Then End
stopDate = InputBox("Enter the Stop Date: (dd/mm/yyyy)")
If stopDate = "" Then End
startDate = Format(startDate, "dd/mm/yyyy")
stopDate = Format(stopDate, "dd/mm/yyyy")
With Worksheets("Prices")
Set r = .Range(.Cells(1, 2), .Cells(65536, 2).End(xlUp))
End With
x = Application.Match(startDate, r, 0)
If IsNumeric(x) Then
startRow = x
Else
MsgBox "Start date not found"
End
End If

x = Application.Match(stopDate, r, 0)
If IsNumeric(x) Then
stopRow = x
Else
MsgBox "End date not found"
End
End If
--------------------


--
murfyang
------------------------------------------------------------------------
murfyang's Profile: http://www.excelforum.com/member.php...o&userid=26702
View this thread: http://www.excelforum.com/showthread...hreadid=471693

 
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
Search, Match, Pull sjkoep Excel Worksheet Functions 1 May 28th 10 12:35 AM
search for match Tami Excel Worksheet Functions 1 February 11th 10 07:21 PM
VLOOKUP and MATCH w/ name search? LTUser54 Excel Worksheet Functions 2 May 22nd 06 04:41 PM
Search and match condition Soniya Excel Programming 1 October 27th 04 03:03 PM
Qn: Best way to search a database to match a last name?? Michael Vaughan Excel Programming 1 September 2nd 04 11:20 PM


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