ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Scroll to top of page code (https://www.excelbanter.com/excel-programming/350493-scroll-top-page-code.html)

peter.thompson[_49_]

Scroll to top of page code
 

I have a worksheet where the first 6 rows are 'frozen'

When a worksheet is activated, I would like the sheet to be 'scrolled
to the top. Tired Range.("A7").select, however the worksheet does no
scroll to the top.

Would appreciate anyone helping with the suggested code to make thi
happen.

Cheers

Peter (new to VBA

--
peter.thompso
-----------------------------------------------------------------------
peter.thompson's Profile: http://www.excelforum.com/member.php...fo&userid=2968
View this thread: http://www.excelforum.com/showthread.php?threadid=50153


Mark Lincoln

Scroll to top of page code
 
Enter this code in the sheet in question:

Private Sub Worksheet_Activate()
Range("A7").Select
End Sub


peter.thompson[_50_]

Scroll to top of page code
 

Hi Mark, I've tried that, the cursor moves to the cell, but the page
doesn't 'scroll up' for some reason...

Cheers

Peter


--
peter.thompson
------------------------------------------------------------------------
peter.thompson's Profile: http://www.excelforum.com/member.php...o&userid=29686
View this thread: http://www.excelforum.com/showthread...hreadid=501532


Norman Jones

Scroll to top of page code
 
Hi Peter,

Try:

'=============
Private Sub Worksheet_Activate()
Application.Goto Reference:=Range("A7"), Scroll:=True
End Sub
'<<=============

This is worksheet event code and should be pasted into the worksheets's code
module (not a standard module and not the workbook's ThisWorkbook module):

Right-click the worksheet's tab
Select 'View Code' from the menu and paste the code.
Alt-F11 to return to Excel.


---
Regards,
Norman


"peter.thompson"
<peter.thompson.21paum_1137370203.5501@excelforu m-nospam.com wrote in
message news:peter.thompson.21paum_1137370203.5501@excelfo rum-nospam.com...

I have a worksheet where the first 6 rows are 'frozen'

When a worksheet is activated, I would like the sheet to be 'scrolled'
to the top. Tired Range.("A7").select, however the worksheet does not
scroll to the top.

Would appreciate anyone helping with the suggested code to make this
happen.

Cheers

Peter (new to VBA)


--
peter.thompson
------------------------------------------------------------------------
peter.thompson's Profile:
http://www.excelforum.com/member.php...o&userid=29686
View this thread: http://www.excelforum.com/showthread...hreadid=501532




peter.thompson[_51_]

Scroll to top of page code
 

Thanks Norman, that did it.

Cheers

Peter


--
peter.thompson
------------------------------------------------------------------------
peter.thompson's Profile: http://www.excelforum.com/member.php...o&userid=29686
View this thread: http://www.excelforum.com/showthread...hreadid=501532


Mark Lincoln

Scroll to top of page code
 
Peter, I'm puzzled -- I get the same behavior both with my code and
with Norman's, and I've never had mine fail in use in any worksheet in
which I've used it.

I'm curious as to why my code didn't work for you. Did you run it in
the worksheet's code module?


peter.thompson[_52_]

Scroll to top of page code
 

Hi Mark,

Am doing a few other things at the same time, see code below. Probabl
why it isn't working in this scenario. Unfortunately I'm too much of
newbie to figure out why!

Sincerely appreciate your asistance.

Public Sub Worksheet_Activate()
Application.ScreenUpdating = False
Password = "djdog"
ActiveSheet.Unprotect Password
Cells.Select
Selection.EntireRow.Hidden = False
Application.Goto Reference:=Range("A7"), Scroll:=True


Cheers

Pete

--
peter.thompso
-----------------------------------------------------------------------
peter.thompson's Profile: http://www.excelforum.com/member.php...fo&userid=2968
View this thread: http://www.excelforum.com/showthread.php?threadid=50153


Mark Lincoln

Scroll to top of page code
 
Public Sub Worksheet_Activate()
Application.ScreenUpdating = False
Password = "djdog"
ActiveSheet.Unprotect Password
Cells.Select
Selection.EntireRow.Hidden = False
Application.Goto Reference:=Range("A7"), Scroll:=True


Peter, I don't know for sure, but I'd think turning off ScreenUpdating
is keeping your original code from working. I've never needed to keep
the screen from updating while using my code. Norman's code forces the
scrolling where your original code (and mine) do not.



All times are GMT +1. The time now is 03:21 AM.

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