Scoll so taht the active cell is in the first line on the screen

W

WalterK

Hi
I would like to write a macro that lets me go fra a button placed in A1 to
for example cell A40 and the row 40 should be the first line on the screen..
I then want the macro to move the cursor 2 rows down and still have row 40 as
the first line on the sceen.

Anybody that can help
 
H

Harald Staff

Sub test()
Range("A42").Select
ActiveWindow.ScrollRow = 40
ActiveWindow.ScrollColumn = 1
End Sub

HTH. Best wishes Harald
 
J

JLGWhiz

Put this in your sheet code module. It will move any cell selected to the
top left cell of the screen.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
ActiveWindow.ScrollRow = Target.Row
ActiveWindow.ScrollColumn = Target.Column
End Sub

However, I do not think you will be totally happy with it.
 
J

JLGWhiz

What you might want to do is put the scroll code behind a button and just use
the button to move the cell up instead of the selection change event.
 

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