HI Could some have a look at below code. It has an error i i cant figure out where it is.
I need to use to search in sheet3 and copy the result to sheet2 after the startdate and enddate i put in.
Please have a look thanks.
You can also look at the sample below.
Thanks
Abjac
Dim sh As Worksheet
Dim LR As Long
Sub SetWorksheet1()
Sheets(3).Activate
Set sh = ThisWorkbook.Sheets(2)
LR = sh.Cells(Rows.Count, "A").End(xlUp).Row
Call searchdate1(sh, LR)
End Sub
Sub searchdate1()
Dim k As Long, j As Long
Dim myWord As String
Dim myRng As Range
linestart:
sdate = InputBox("Input Startdate ")
enddate = InputBox("Input Enddate ")
If sdate = "" Or enddate = "" Then Exit Sub
On Error Resume Next
Nsdate = CDate(sdate)
Nenddate = CDate(enddate)
On Error GoTo 0
drow = 2
For k = 4 To Cells(Rows.Count, "L").End(xlUp).Row
fdate = Range("L" & k)
If fdate >= Nsdate And fdate <= Nenddate Then
sh.Rows(drow) = Rows(k).Value
drow = drow + 1
ffound = ffound + 1
End If
Next k
If ffound = 0 Then
MsgBox "Not found, Try again"
GoTo linestart
End If
End Sub
Bookmarks