Hi, I am writing a code in which the user enters 2 dates, start date and end date. There is a database workbook, where each worksheet represents a project. What I have to find out is the name of the projects whose starting date is more than start date that the user entered and the ending date is less than the end date.These project names should be displyed as result in another workbook, hyperlinked to the corresponding sheets in the datebase workbook.
Following is the code that I wrote for that.
But this code is not working. Could someone please help me in this? Please
Following is the code that I wrote for that.
Code:
Dim date1 As Date Dim date2 As DateDim start_date As DateDim end_date As DateDim starting As RangeDim finishing As RangeIf date1 = Null Or date2 = Null Then Else For Each sh In DestBook.Worksheets If sh.Range("B25").Value <= date1 And sh.Range("B26").Value >= date2 Then start_date = sh.Range("B25").Value end_date = sh.Range("B26").Value Set starting = sh.UsedRange.Find(What:=start_date, LookIn:=xlValues) Set finishing = sh.UsedRange.Find(What:=sh.Range("B26").Value, LookIn:=xlValues) shOutput.Hyperlinks.Add _ Anchor:=shOutput.Cells(Rows.Count, "A").End(xlUp).Offset(1, 0), _ Address:=DestBook.FullName, _ SubAddress:="'" & starting.Parent.Name & "'" & "!" & starting.Address, _ TextToDisplay:=sh.Name Exit Sub End IfEnd If