Go to macro?

T

teeb

In cloumn A i have a list of of dates. As there are so many I'm tryin
to create a button that will look at a date that a user types in a cel
(eg D3) and then goes to the cell in column A for the same date.

I know that this is the same as the go to function but I want to ensur
that the format is always correct.

Any help with a macro would be appreciated.

:confused
 
F

Frank Stone

Hi,
Try this:
sub macFind()
Cells.Find(What:=Range("D3").Value, After:=ActiveCell, _
LookIn:=xlFormulas, LookAt:=xlPart, SearchOrder:= _
lByRows, SearchDirection:=xlNext, MatchCase:= _
False).Activate
End Sub
 
T

teeb

Thanks for response, tried suggestion below but getting an error:


Runtime error '1004'

Unable to get Find property of the Range class

any other ideas
 
D

Dave Peterson

How about this version:

Option Explicit
Sub testme()

Dim res As Variant
Dim myCell As Range
Dim myRng As Range
Dim wks As Worksheet

Set wks = ActiveSheet
With wks
Set myCell = .Range("d3")
Set myRng = .Range("a4", .Cells(.Rows.Count, "A").End(xlUp))
If IsDate(myCell.Value) Then
res = Application.Match(CLng(myCell.Value), myRng, 0)
If IsError(res) Then
MsgBox myCell.Value & " wasn't found"
Else
Application.Goto myRng(res)
End If
End If
End With
End Sub
 
Top