View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default Selecting Next Worksheet

Maybe...

Option Explicit
Sub Timesheet_Format()
Dim sht As Worksheet
For Each sht In ThisWorkbook.Worksheets
sht.select
'ACTIONS TO BE DONE
Next sht
End Sub

But for the most part, it's not necessary to select the worksheet to work with
it.

If you qualify your ranges (or whatever objects your actions work on), it may
work quicker.

Option Explicit
Sub Timesheet_Format()
Dim sht As Worksheet
For Each sht In ThisWorkbook.Worksheets
sht.range("a1").clearcontents
'ACTIONS TO BE DONE
Next sht
End Sub



BSII wrote:

I'm looking for some code to perform the same group of operations on each
worksheet in a workbook. It seems to be a very simple operation, but I can't
seem to get it to work. I have tried the following:

Sub Timesheet_Format()

Dim sht As Worksheet
For Each sht In ThisWorkbook.Worksheets

' ACTIONS TO BE DONE

Next

End Sub

It runs ok for the current worksheet, but doesn't go on to any of the
others. Any suggestions on what I'm doing wrong?

Thanks...


--

Dave Peterson