• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

search date

i have this code
for what i need is perfect but i wanted to make something more
so this code search in a sheet called 2018 and find today day and then go to another cell (offset)
i would like to make a search box to find desire date in the year for example 10 January
i make some tests and read guides but this part "Cells.Find(What:=Format(Now(),"
is confusing me. any help how to say it the date that i want?
my thought was to write the date in cell a1 copied and then search the copied value

[Sub Searchday()

Sheets("2018").Select
Range("A1").Select
Selection.Copy
Range("V2:V17000").Select
Cells.Find(What:=Format(Now(), "dd mm YYYY"), After:=ActiveCell, LookIn:=xlValues, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
ActiveWindow.ScrollRow = ActiveCell.Row
ActiveCell.Offset(-3, -21).Select
End Sub]
 
Hi,
Try (search date in A1)
Code:
Sub Searchday()
Sheets("2018").Activate
Cells.Find(What:=[A1], SearchOrder:=xlRows, SearchDirection:=xlPrevious, LookIn:=xlValues).Offset(-3, -21).Select
End Sub
Note: You should avoid select or activate, but without an example I can't give a better answer.
 
Hi following code will select current date in range("V2:V17000")
Code:
Sub srchdate()

    Dim mycell As Variant
 
    mycell = Range("V2:V17000").Find(Date).Address
 
    Range(mycell).Select
 
End Sub
 
with couple changes the code worked
Code:
Sub Macro2()
  Dim dDate As Date
  Dim str As String
  Dim mycell As Variant
  
  str = InputBox("EnterDateHere")
  Range("V2:V17000").Select
  dDate = CDate(str)
  Cells.Find(What:=str, After:=ActiveCell, LookIn:=xlValues, _
  LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
  MatchCase:=False, SearchFormat:=False).Activate
  ActiveCell.Offset(-3, -21).Select
End Sub

thank you all
 
Last edited by a moderator:
Back
Top