Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Search, Match, Pull | Excel Worksheet Functions | |||
search for match | Excel Worksheet Functions | |||
VLOOKUP and MATCH w/ name search? | Excel Worksheet Functions | |||
Search and match condition | Excel Programming | |||
Qn: Best way to search a database to match a last name?? | Excel Programming |