Using For Next to reset Pge Brk Preview on all sheets

  • Thread starter Thread starter Far
  • Start date Start date
F

Far

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
 
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
 
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
 
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
 
There is no Worksheets collection

This is completely incorrect.

There certainly is a worksheets collection.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top