VBA code to select a cell so it appears in the top left of the screen

F

Forum Freak

Hi

I would like to modify the following code (supplied by Tom Ogilvy I think)

Column A contains dates and blank cells, code asks for date then selects it.

It would look really neat if the selected cell appeared in the top left of
the screen.

Can it be done?

TIA

Kenny W
Using XP Pro and Office 2003

Code below here
---------------------
Sheets("units").Select
ans = InputBox("Please enter W/E required as date (dd/mm/yy)")
If IsDate(ans) Then
dt = CDate(ans)
res = Application.Match(CLng(dt), Range("A1:A365"), 0)
If Not IsError(res) Then
Range("A1:A365")(res).Activate
Else
MsgBox ans & " was not matched"
End If
Else
If Len(Trim(ans)) = 0 Then
MsgBox "You hit cancel"
Else
MsgBox ans & " Not recognized as a date"
End If
End If
Sheets("units").Select
ActiveCell.Range("A1").Select
 
R

Roger Govier

Hi Kenny

If Not IsError(res) Then
Range("A1:A365")(res).Activate
ActiveWindow.ScrollRow = res
Else
 
P

Peter T

Another one -

If Not IsError(res) Then
Application.Goto Range("A1:A365")(res), True
Else

Regards,
Peter T
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top