Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Moving through sheets
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Moving through sheets
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 -----Original Message----- 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 . |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Moving through sheets
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 -- Regards, Tom Ogilvy "Keith Emery" wrote in message ... 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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Moving Data between sheets in the same workbook and moving data between Workbooks. | Excel Worksheet Functions | |||
Moving Between Sheets | Excel Discussion (Misc queries) | |||
Moving through sheets | Excel Discussion (Misc queries) | |||
moving between sheets | Excel Programming | |||
Moving data to sheets | Excel Programming |