Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
All Worksheets
Hello,
I am trying to use code that will perform an action on every worksheet in an excel file. I have tried using: Dim wks As Worksheet For Each wks In ActiveWorkbook.Worksheets '''''''''''''some action which will move around on the worksheet''''''''''''''''' Next wks I get an error when using this. Is there another method to go to each worksheet that is in the file and perform the same action. Thank You, |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
All Worksheets
If you're selecting ranges on those worksheets, then you have to select that
sheet first. Dim wks As Worksheet For Each wks In ActiveWorkbook.Worksheets wks.select '<-- added '''''''''''''some action which will move around on the worksheet''''' Next wks But you don't usually need to select a range to work on it. wks.select range("a1").select selection.clearcontents could be written as: wks.range("a1").clearcontents tjh wrote: Hello, I am trying to use code that will perform an action on every worksheet in an excel file. I have tried using: Dim wks As Worksheet For Each wks In ActiveWorkbook.Worksheets '''''''''''''some action which will move around on the worksheet''''''''''''''''' Next wks I get an error when using this. Is there another method to go to each worksheet that is in the file and perform the same action. Thank You, -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How use info in Excel shared worksheets to create new worksheets | Excel Worksheet Functions | |||
How do i assign the ActiveWorkbook.Worksheets to a worksheets object? | Excel Worksheet Functions | |||
Assigning Cells in worksheets to other data in other worksheets. | Excel Discussion (Misc queries) | |||
Sort Numerically Worksheets via VB when creating a new worksheets | Excel Programming | |||
Need code to protect worksheets - amount of worksheets varies | Excel Programming |