• 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.

Find Date (Using VBA)

ravikiran

Member
Hi Excel Gurus,


I need help with this small code.


I know how to find a date from a range. I tried using the same code where the date is derived through a formula (I am adding up date by 1 day to each subsequent cells and use "FIND" in this range to get the column of the date). Surprisingly the code didn't work and not returning the col of the date after find.

[pre]
Code:
Sub Sample()

TDate = Cells(1, 1)
TDate = CDate(TDate)

Set FoundCell = Range("2:2").Find(what:=TDate, LookIn:=xlFormulas)
On Error Resume Next

Col = FoundCell.Column

MsgBox Col

End Sub
[/pre]

Thanks in advance,


Regards,

Ravi.
 
Try this:

[pre]
Code:
Sub Sample()

TDate = Cells(1, 1)
TDate = CDate(TDate)

Set FoundCell = Range("2:2").Find(What:=TDate, LookIn:=xlValues)
On Error Resume Next

Col = FoundCell.Column

MsgBox Col

End Sub
[/pre]
 
Back
Top