ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macro to Move Selected Cell to Top of Screen (https://www.excelbanter.com/excel-programming/315300-macro-move-selected-cell-top-screen.html)

snsd[_2_]

Macro to Move Selected Cell to Top of Screen
 

Bingo!

Here's one way of doing it.

Create a macro called "TopOfScreen". This essentially takes the activ
cell and repositions it to the top of the screen. The only differenc
here is that you don't have to specify a cell reference as long a
you've selected the cell you want. Then, to rid the challenge of th
left column shifting to the right, use the ActiveCell.Offset comman
where the first number represents how many rows to reposition the row
and the second number represents how many columns to shift the columns
In this case, I just need to shift the columns one to the left to ge
column A back on the screen.

Sub TopOfScreen()
ActiveCell.Select
With ActiveWindow
.ScrollColumn = ActiveCell.Column
.ScrollRow = ActiveCell.Row
ActiveCell.Offset(0, -1).Select
End With
End Sub

Thanks for getting the ball rolling.

Dav

--
sns
-----------------------------------------------------------------------
snsd's Profile: http://www.excelforum.com/member.php...fo&userid=1591
View this thread: http://www.excelforum.com/showthread.php?threadid=27390


Nick Hodge

Macro to Move Selected Cell to Top of Screen
 
You could download an example to scroll all sheets to the top left cell at

http://www.nickhodge.co.uk/files/vba...heetsToTop.xls

--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
HIS


"snsd" wrote in message
...

Bingo!

Here's one way of doing it.

Create a macro called "TopOfScreen". This essentially takes the active
cell and repositions it to the top of the screen. The only difference
here is that you don't have to specify a cell reference as long as
you've selected the cell you want. Then, to rid the challenge of the
left column shifting to the right, use the ActiveCell.Offset command
where the first number represents how many rows to reposition the rows
and the second number represents how many columns to shift the columns.
In this case, I just need to shift the columns one to the left to get
column A back on the screen.

Sub TopOfScreen()
ActiveCell.Select
With ActiveWindow
ScrollColumn = ActiveCell.Column
ScrollRow = ActiveCell.Row
ActiveCell.Offset(0, -1).Select
End With
End Sub

Thanks for getting the ball rolling.

Dave


--
snsd
------------------------------------------------------------------------
snsd's Profile:
http://www.excelforum.com/member.php...o&userid=15910
View this thread: http://www.excelforum.com/showthread...hreadid=273904





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

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