Scrolling fully top left

Farback

Board Regular
Joined
Mar 27, 2009
Messages
149
I have a Leave Chart that is used by many people, which has filters on the Name and Department Columns. In order to ensure that all Filters are cancelled, I have this code, called in the workbook open event:
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p> </o:p>
Sub unfilter()<o:p></o:p>
On Error Resume Next<o:p></o:p>
Dim wrksht As Worksheet<o:p></o:p>
For Each wrksht In ThisWorkbook.Worksheets<o:p></o:p>
wrksht.ShowAllData<o:p></o:p>
Next wrksht<o:p></o:p>
End Sub
<o:p> </o:p>
I also have some code to ensure that worksheets are scrolled fully top-left when activated:
<o:p> </o:p>
With ActiveWindow<o:p></o:p>
.ScrollRow = 1<o:p></o:p>
.ScrollColumn = 1<o:p></o:p>
End With
<o:p> </o:p>
The problem is that this will apply whenever the worksheet is activated, which can be annoying if someone is browsing through the workbook. What I want to do is combine the two. I have tried:
<o:p> </o:p>
Sub unfilter()<o:p></o:p>
On Error Resume Next<o:p></o:p>
Dim wrksht As Worksheet<o:p></o:p>
For Each wrksht In ThisWorkbook.Worksheets<o:p></o:p>
wrksht.ShowAllData<o:p></o:p>
wrksht.ScrollRow = 1<o:p></o:p>
wrksht.ScrollColumn = 1<o:p></o:p>
Next wrksht<o:p></o:p>
End Sub
<o:p> </o:p>
but I get a compile error. Does anyone know how to solve this?
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
I really hate having to use the .select method, but I think that it is appropriate here:

Code:
Public Sub topleft()
Dim ws As Worksheet
Application.ScreenUpdating = False
For Each ws In ActiveWorkbook.Worksheets
    ws.Select
    ws.ShowAllData
    Range("A1").Select
Next ws
Applciation.ScreenUpdating = True
End Sub
 
Upvote 0
Perhaps

Code:
Sub unfilter()
On Error Resume Next
Dim wrksht As Worksheet
For Each wrksht In ThisWorkbook.Worksheets
wrksht.ShowAllData
Application.Goto wrksht.Range("A1")
Next wrksht
End Sub
 
Upvote 0
Thanks for the reply both. Unfortunately neither work. I have columns A-C frozen to show headers. I have tried using D6, but it seems to select the cell under the frozen range. I really need to know how to fully scroll the worksheet Top-Right before A1 is selected.
 
Upvote 0
This worked for me with panes frozen

Code:
Sub unfilter()
On Error Resume Next
Dim wrksht As Worksheet
For Each wrksht In ThisWorkbook.Worksheets
Application.Goto wrksht.Range("A1")
Next wrksht
End Sub
 
Upvote 0
Hi VoG

I tried that, and it definitely doesn't work on mine, it just seems to open the workbook with the last worksheet selected, but all the sheets are at different scroll states.
 
Upvote 0

Forum statistics

Threads
1,224,613
Messages
6,179,903
Members
452,948
Latest member
Dupuhini

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