Moving through sheets

  • Thread starter Thread starter Keith Emery
  • Start date Start date
K

Keith Emery

I want to run a routine on each sheet in the workbook. As
the numberf of sheets may change, I would prefer not to
refer to them by name.

Can anyone advise on the With/End With or For / Next code
into which I can put my routine? So far I have got

Sub UpdateFalseNew()
Dim wrkBook As Workbook
Dim wrkSht As Sheets

wrkBook = ThisWorkbook

For Each wrkSht In wrkBook
wrkSht.Select
setupdatefalse
Next wrkSht

End Sub
 
Hello Keith

Below is a very simple Macro i wrote that gives every
sheet in a workbook the same print area. Instead of
the 'ws.PageSetup.PrintArea = "$A:$I"' you could enter
another routine.

Sub AllSheetsSamePrintArea()
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
ws.PageSetup.PrintArea = "$A:$I"
Next ws
End Sub
 
Sub UpdateFalseNew()
Dim wrkBook As Workbook
Dim wrkSht As Object

set wrkBook = ThisWorkbook

For Each wrkSht In wrkBook.Sheets
wrkSht.Select
setupdatefalse
Next wrkSht

End Sub

or if only worksheets (the more likely situation)

Sub UpdateFalseNew()
Dim wrkBook As Workbook
Dim wrkSht As WorkSheet
set wrkBook = ThisWorkbook

For Each wrkSht In wrkBook.WorkSheets
wrkSht.Select
setupdatefalse
Next wrkSht

End Sub
 

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

Similar Threads


Back
Top