ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Programmatically scrolling to top (https://www.excelbanter.com/excel-programming/330107-programmatically-scrolling-top.html)

VanS[_2_]

Programmatically scrolling to top
 
Hello,
I have an Excel VBA app and I need automatically scroll to the top left
(cell A1) when each worksheet is selected and activated. I tried using the
Select, Activate and Show methods for the range in the Worksheet_Activate sub
but they didn't work.
Any ideas on a simple technique to do so?
Thanks, God bless
Van

david mcritchie

Programmatically scrolling to top
 
see
http://www.mvps.org/dmcritchie/excel...oc.htm#TopLeft

specifically:
Application.Goto Reference:=Cells(1, 1), Scroll:=True
---
HTH,
David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001]
My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page: http://www.mvps.org/dmcritchie/excel/search.htm

"VanS" wrote in message ...
Hello,
I have an Excel VBA app and I need automatically scroll to the top left
(cell A1) when each worksheet is selected and activated. I tried using the
Select, Activate and Show methods for the range in the Worksheet_Activate sub
but they didn't work.
Any ideas on a simple technique to do so?
Thanks, God bless
Van




K Dales[_2_]

Programmatically scrolling to top
 
Where did you put the code, and how did you write it? Sounds like the idea
should work; you would need to put the code in each worksheet's module,
though, to get it to work for every sheet. This code should work:

Private Sub Worksheet_Activate()

Range("A1").Select

End Sub


"VanS" wrote:

Hello,
I have an Excel VBA app and I need automatically scroll to the top left
(cell A1) when each worksheet is selected and activated. I tried using the
Select, Activate and Show methods for the range in the Worksheet_Activate sub
but they didn't work.
Any ideas on a simple technique to do so?
Thanks, God bless
Van


Daniel CHEN

Programmatically scrolling to top
 

The following codes worked with me.
I think it should work with you too, if you do not have any sepcial stuff in
your sheets.

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

===== * ===== * ===== * =====
Daniel CHEN


www.Geocities.com/UDQServices
Free Data Processing Add-in<

===== * ===== * ===== * =====

"VanS" wrote in message
...
Hello,
I have an Excel VBA app and I need automatically scroll to the top left
(cell A1) when each worksheet is selected and activated. I tried using the
Select, Activate and Show methods for the range in the Worksheet_Activate
sub
but they didn't work.
Any ideas on a simple technique to do so?
Thanks, God bless
Van




Harald Staff

Programmatically scrolling to top
 
Hi Van

The provided solutions will make A1 the selected cell. You may or may not
want that. If not, put this in the ThisWorkbook module:

Private Sub Workbook_SheetActivate(ByVal Sh As Object)
ActiveWindow.ScrollColumn = 1
ActiveWindow.ScrollRow = 1
End Sub

HTH. Best wishes Harald


"VanS" skrev i melding
...
Hello,
I have an Excel VBA app and I need automatically scroll to the top left
(cell A1) when each worksheet is selected and activated. I tried using the
Select, Activate and Show methods for the range in the Worksheet_Activate

sub
but they didn't work.
Any ideas on a simple technique to do so?
Thanks, God bless
Van




VanS[_2_]

Programmatically scrolling to top
 
Thanks to all of you that replied.
As indicated the Select method doesn't work though it seems it should. Your
solutions David and Harald did, so appreciate you help.
God bless
Van

"Harald Staff" wrote:

Hi Van

The provided solutions will make A1 the selected cell. You may or may not
want that. If not, put this in the ThisWorkbook module:

Private Sub Workbook_SheetActivate(ByVal Sh As Object)
ActiveWindow.ScrollColumn = 1
ActiveWindow.ScrollRow = 1
End Sub

HTH. Best wishes Harald


"VanS" skrev i melding
...
Hello,
I have an Excel VBA app and I need automatically scroll to the top left
(cell A1) when each worksheet is selected and activated. I tried using the
Select, Activate and Show methods for the range in the Worksheet_Activate

sub
but they didn't work.
Any ideas on a simple technique to do so?
Thanks, God bless
Van






All times are GMT +1. The time now is 02:30 PM.

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