ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   VBA code to scroll all the way to the top (https://www.excelbanter.com/excel-programming/280367-vba-code-scroll-all-way-top.html)

lothario[_32_]

VBA code to scroll all the way to the top
 
Hi,

This spreadsheet contains 5 sheets.
Each sheet has more than 3000 rows of data.

Can you tell me the VBA code:
a. Which takes the vertical scroll all the way to the top.
b. Where shold the code be located such that each time the user
clicks on tab of the respective sheet then this code gets
executed. So the user can scroll up and down in any sheet
but whenever he goes to another sheet the vertical scroll
is always at the top.

Thanks.
Luther



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/


Harald Staff

VBA code to scroll all the way to the top
 
Hi Luther

Paste this in the ThisWorkbook module:

Private Sub Workbook_SheetActivate(ByVal Sh As Object)
ActiveWindow.ScrollRow = 1
Cells(1, 1).Select
End Sub

--
HTH. Best wishes Harald
Followup to newsgroup only please

"lothario" skrev i melding
...
Hi,

This spreadsheet contains 5 sheets.
Each sheet has more than 3000 rows of data.

Can you tell me the VBA code:
a. Which takes the vertical scroll all the way to the top.
b. Where shold the code be located such that each time the user
clicks on tab of the respective sheet then this code gets
executed. So the user can scroll up and down in any sheet
but whenever he goes to another sheet the vertical scroll
is always at the top.

Thanks.
Luther



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/




Chip Pearson

VBA code to scroll all the way to the top
 
Luther,

Put the following in the ThisWorkbook code module.

Private Sub Workbook_SheetActivate(ByVal Sh As Object)
If TypeOf Sh Is Excel.Worksheet Then
Application.Goto Sh.Range("A1"), True
End If
End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"lothario" wrote in message
...
Hi,

This spreadsheet contains 5 sheets.
Each sheet has more than 3000 rows of data.

Can you tell me the VBA code:
a. Which takes the vertical scroll all the way to the top.
b. Where shold the code be located such that each time the user
clicks on tab of the respective sheet then this code gets
executed. So the user can scroll up and down in any sheet
but whenever he goes to another sheet the vertical scroll
is always at the top.

Thanks.
Luther



------------------------------------------------
~~ Message posted from
http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/




lothario[_33_]

VBA code to scroll all the way to the top
 
Thanks guys.
This helped.



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/



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

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