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

  • Thread starter Thread starter Forum Freak
  • Start date Start date
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
 
Hi Kenny

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

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

Regards,
Peter T
 
Back
Top