ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Scoll so taht the active cell is in the first line on the screen (https://www.excelbanter.com/excel-programming/423511-scoll-so-taht-active-cell-first-line-screen.html)

WalterK

Scoll so taht the active cell is in the first line on the screen
 
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

Harald Staff[_2_]

Scoll so taht the active cell is in the first line on the screen
 
Sub test()
Range("A42").Select
ActiveWindow.ScrollRow = 40
ActiveWindow.ScrollColumn = 1
End Sub

HTH. Best wishes Harald

"WalterK" wrote in message
...
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



JLGWhiz

Scoll so taht the active cell is in the first line on the screen
 
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.

"WalterK" wrote:

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


JLGWhiz

Scoll so taht the active cell is in the first line on the screen
 
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.

"WalterK" wrote:

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



All times are GMT +1. The time now is 07:12 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com