Home |
Search |
Today's Posts |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Selecting a row in a worksheet | Excel Worksheet Functions | |||
Sorting a range on another worksheet without selecting the worksheet | Excel Programming | |||
Help! Selecting a Worksheet with VBA | Excel Programming | |||
selecting cell range in other worksheet without switching to worksheet | Excel Programming | |||
Selecting Last Worksheet | Excel Programming |