Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Moving Data between sheets in the same workbook and moving data between Workbooks. Alison Brown Excel Worksheet Functions 0 February 10th 09 01:03 AM
Moving Between Sheets PaolaAndrea Excel Discussion (Misc queries) 1 December 2nd 08 05:15 PM
Moving through sheets izlopez Excel Discussion (Misc queries) 1 January 13th 05 08:33 PM
moving between sheets aschneid Excel Programming 2 May 11th 04 10:07 AM
Moving data to sheets Dave Peterson[_3_] Excel Programming 0 September 4th 03 03:53 PM


All times are GMT +1. The time now is 01:34 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"