Align all worksheets

Jim

New Member
Joined
Feb 17, 2002
Messages
1
This is a continuation from Friday.

This gets partway there. It positions all worksheets the same in the window but doesn't make the same cell the active cell in each. Ideally, it would also return to the sheet that was selected as the active sheet upon completion.

: : I got some VBA code from one of the great Excel sites a while back that I can't find now. It caused every worksheet in the workbook to be positioned the same in the window and have the same active cell, i.e. launch it while active cell is FF5000 and every sheet would align with FF5000 in top left of window position. Would truly appreciate if anyone could point me to it again.

:
: Sub Scroll_To_ActiveCell()
: Dim ws As Worksheet, rng As String
: rng = ActiveCell.Address(False, False)
: Application.ScreenUpdating = False
: For Each ws In ActiveWorkbook.Worksheets
: ws.Activate
: With ActiveWindow
: .ScrollRow = Range(rng).Row
: .ScrollColumn = Range(rng).Column
: End With
: Next
: End Sub
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Just need to select the cell, the code below should finalize:

Sub Scroll_To_ActiveCell()
Dim ws As Worksheet, rng As String
ActiveWorkbook.Names.Add Name:="Money", RefersToR1C1:=Selection
rng = ActiveCell.Address(False, False)
Application.ScreenUpdating = False
For Each ws In ActiveWorkbook.Worksheets
ws.Activate
Range(rng).Select
With ActiveWindow
.ScrollRow = Range(rng).Row
.ScrollColumn = Range(rng).Column
End With
Next
Application.Goto Reference:="Money"
ActiveWorkbook.Names("Money").Delete
End Sub


Cheers,

Nate
This message was edited by NateO on 2002-02-18 12:01
 
Upvote 0
Or:

Sub Scroll_To_ActiveCell2()
Dim ws As Worksheet, rng As String
money = ActiveSheet.Name
rng = ActiveCell.Address(False, False)
Application.ScreenUpdating = False
For Each ws In ActiveWorkbook.Worksheets
ws.Activate
Range(rng).Select
With ActiveWindow
.ScrollRow = Range(rng).Row
.ScrollColumn = Range(rng).Column
End With
Next
Sheets(money).Select
End Sub

Cheers, Nate
This message was edited by NateO on 2002-02-18 12:04
 
Upvote 0

Forum statistics

Threads
1,213,501
Messages
6,114,010
Members
448,543
Latest member
MartinLarkin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top