LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Selecting Next Worksheet

Just a note...

You may want to make it so the module and the subroutine have different names.

PERSONAL.XLS!Mod_TimeSub2.TimeSub2

I've seen bad things happen when both the module and the procedure have the same
name.

BSII wrote:

Thanks everyone - my apologies for not being more specific. What I'm really
trying to do is write a subroutine tha that will run a couple of subroutines
on each worksheet in my workbook. The current code is:

Sub Timesheet_Format()

Dim sht As Worksheet

For Each sht In ThisWorkbook.Worksheets

ThisWorkbook.Application.Run "PERSONAL.XLS!TimeSub2.TimeSub2"
Application.Wait Now + TimeValue("00:00:01") 'Delay

ThisWorkbook.Application.Run "PERSONAL.XLS!TimeSub3.TimeSub3"
Application.Wait Now + TimeValue("00:00:01") 'Delay

ThisWorkbook.Application.Run "PERSONAL.XLS!TimeSub4.TimeSub4"
ThisWorkbook.Application.Run "PERSONAL.XLS!TimeSub5.TimeSub5"
ThisWorkbook.Application.Run "PERSONAL.XLS!TimeSub6.TimeSub6"
Next

End Sub

The "TimeSubs" are subroutines that format and arrange my data. From the
other suggestions, it sounds like I'm not using the "For Each" correctly. Is
there a better way to do this?

"Gary Keramidas" wrote:

post your code. maybe you're not qualifying the ranges.

for example:

this will not work:, it will only enter test into the active sheet:
Sub Timesheet_Format()
Dim sht As Worksheet
For Each sht In ThisWorkbook.Worksheets
Range("A1") = "test"
Next
End Sub

this will:

Sub Timesheet_Format()
Dim sht As Worksheet
For Each sht In ThisWorkbook.Worksheets
sht.Range("A1") = "test"
Next
End Sub
--


Gary


"BSII" wrote in message
...
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


 
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
Selecting a row in a worksheet Rochelle in Melbourne Excel Worksheet Functions 1 April 9th 09 11:34 AM
Sorting a range on another worksheet without selecting the worksheet [email protected] Excel Programming 1 December 21st 06 11:06 PM
Help! Selecting a Worksheet with VBA [email protected] Excel Programming 7 December 18th 06 08:52 PM
selecting cell range in other worksheet without switching to worksheet suzetter[_4_] Excel Programming 4 June 22nd 05 08:55 PM
Selecting Last Worksheet Alex Excel Programming 7 September 26th 04 09:35 PM


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

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

About Us

"It's about Microsoft Excel"