Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
tjh tjh is offline
external usenet poster
 
Posts: 96
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default 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
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
How use info in Excel shared worksheets to create new worksheets dkc Excel Worksheet Functions 0 June 28th 07 08:36 PM
How do i assign the ActiveWorkbook.Worksheets to a worksheets object? TS Excel Worksheet Functions 2 December 27th 06 02:49 PM
Assigning Cells in worksheets to other data in other worksheets. David McRitchie Excel Discussion (Misc queries) 0 November 27th 04 06:15 PM
Sort Numerically Worksheets via VB when creating a new worksheets John Excel Programming 6 June 1st 04 07:21 AM
Need code to protect worksheets - amount of worksheets varies Sandy[_3_] Excel Programming 1 September 9th 03 02:17 AM


All times are GMT +1. The time now is 11:52 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"