ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Using For Next to reset Pge Brk Preview on all sheets (https://www.excelbanter.com/excel-programming/295928-using-next-reset-pge-brk-preview-all-sheets.html)

Far

Using For Next to reset Pge Brk Preview on all sheets
 

I am trying to reset the following for each worksheet in
the workbook; however am getting errors on
the "Window.View = xlNormalView" (I am am trying to learn
the Object Model)Similar iss below w/ resetting pointer

Reset "Page Break Preview" for each worksheet in the
workbook; so view is set to "Normal" on each worksheet

Sub Set_Page_Preview_Normal()
For Each wks In Worksheets
Window.View = xlNormalView
Next wks
End Sub

' Reset Cell pointer in worksheet so view is at top of
page on each worksheet

Sub Set_Cell_Pointer_A1()
For Each wks In Worksheets
wks.Range("A1").Select
Next wks
End Sub

Chris

Using For Next to reset Pge Brk Preview on all sheets
 

There is no Worksheets collection, there is a Sheets collection

Sub Set_Page_Preview_Normal(
For Each sh In Sheet
Window.View = xlNormalVie
Next
End Su
----- Far wrote: ----


I am trying to reset the following for each worksheet in
the workbook; however am getting errors on
the "Window.View = xlNormalView" (I am am trying to learn
the Object Model)Similar iss below w/ resetting pointe

Reset "Page Break Preview" for each worksheet in the
workbook; so view is set to "Normal" on each workshee

Sub Set_Page_Preview_Normal(
For Each wks In Worksheet
Window.View = xlNormalVie
Next wk
End Su

' Reset Cell pointer in worksheet so view is at top of
page on each workshee

Sub Set_Cell_Pointer_A1(
For Each wks In Worksheet
wks.Range("A1").Selec
Next wk
End Su


chris: ur code improper also

Using For Next to reset Pge Brk Preview on all sheets
 
try this
Sub Set_Cell_Pointer_A1(
For Each Sh In Sheet
Sh.Selec
ActiveWindow.View = xlNormalVie
Nex
End Su


----- Far wrote: ----


I am trying to reset the following for each worksheet in
the workbook; however am getting errors on
the "Window.View = xlNormalView" (I am am trying to learn
the Object Model)Similar iss below w/ resetting pointe

Reset "Page Break Preview" for each worksheet in the
workbook; so view is set to "Normal" on each workshee

Sub Set_Page_Preview_Normal(
For Each wks In Worksheet
Window.View = xlNormalVie
Next wk
End Su

' Reset Cell pointer in worksheet so view is at top of
page on each workshee

Sub Set_Cell_Pointer_A1(
For Each wks In Worksheet
wks.Range("A1").Selec
Next wk
End Su


Paulw2k

Using For Next to reset Pge Brk Preview on all sheets
 
Hi,

1. Best practice is to declare your variables.
2. Worksheets belong to a workbook, in this instance "ActiveWorkbook"
3. To change the view of a worksheet it must be selected.
4. The View property belongs to the window in which the sheet is viewed.
5. To select a particular cell on each sheet, the sheet should be the active
one.


Sub Set_Page_Preview_Normal()
Dim wks As Worksheet

For Each wks In ActiveWorkbook.Worksheets
wks.Select
ActiveWindow.View = xlNormalView
Next wks


End Sub

Sub Set_Cell_Pointer_A1()
Dim wks As Worksheet

For Each wks In ActiveWorkbook.Worksheets
wks.Select
Range("A1").Select
Next wks
End Sub



Regards

Paul


"Far" wrote in message
...

I am trying to reset the following for each worksheet in
the workbook; however am getting errors on
the "Window.View = xlNormalView" (I am am trying to learn
the Object Model)Similar iss below w/ resetting pointer

Reset "Page Break Preview" for each worksheet in the
workbook; so view is set to "Normal" on each worksheet

Sub Set_Page_Preview_Normal()
For Each wks In Worksheets
Window.View = xlNormalView
Next wks
End Sub

' Reset Cell pointer in worksheet so view is at top of
page on each worksheet

Sub Set_Cell_Pointer_A1()
For Each wks In Worksheets
wks.Range("A1").Select
Next wks
End Sub




Tom Ogilvy

Using For Next to reset Pge Brk Preview on all sheets
 
There is no Worksheets collection

This is completely incorrect.

There certainly is a worksheets collection.

--
Regards,
Tom Ogilvy



"chris" wrote in message
...

There is no Worksheets collection, there is a Sheets collection.

Sub Set_Page_Preview_Normal()
For Each sh In Sheets
Window.View = xlNormalView
Next
End Sub
----- Far wrote: -----


I am trying to reset the following for each worksheet in
the workbook; however am getting errors on
the "Window.View = xlNormalView" (I am am trying to learn
the Object Model)Similar iss below w/ resetting pointer

Reset "Page Break Preview" for each worksheet in the
workbook; so view is set to "Normal" on each worksheet

Sub Set_Page_Preview_Normal()
For Each wks In Worksheets
Window.View = xlNormalView
Next wks
End Sub

' Reset Cell pointer in worksheet so view is at top of
page on each worksheet

Sub Set_Cell_Pointer_A1()
For Each wks In Worksheets
wks.Range("A1").Select
Next wks
End Sub





All times are GMT +1. The time now is 02:24 AM.

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