Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 38
Default For Each Next

I'm feeling like a dummy at the moment. I'm using the For Each statement
to cycle through all sheets in the activeworkbook, and perform actions.
However, I have not used them befoer, and need help. This is what I
have:

Dim wksht As Worksheet
Application.ScreenUpdating = False
For Each wksht In ActiveWorkbook

'code to perform actions

Next wksht

But I get the error, "Object doesn't support this property or method".
Help! Thanks.

*** Sent via Developersdex http://www.developersdex.com ***
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default For Each Next

"Darrin Henshaw" wrote in message
...
I'm feeling like a dummy at the moment. I'm using the For Each statement
to cycle through all sheets in the activeworkbook, and perform actions.
However, I have not used them befoer, and need help. This is what I
have:

Dim wksht As Worksheet
Application.ScreenUpdating = False
For Each wksht In ActiveWorkbook

'code to perform actions

Next wksht

But I get the error, "Object doesn't support this property or method".
Help! Thanks.


Does this help?

For Each wksht in ActiveWorkbook.Worksheets
' insert your code here
next wksht


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 38
Default For Each Next

At least I don't get the error now. But what does happen is that the
actions I need to perform are only happening in the activeworksheet, not
any of the others. Here's an update to the code:

Dim wksht As Worksheet
Application.ScreenUpdating = False

For Each wksht In ActiveWorkbook.Worksheets

Point to note, this same thing happens if I use Sheets, instead of the
ActiveWorkbook. Thanks.

*** Sent via Developersdex http://www.developersdex.com ***
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 703
Default For Each Next

Are you performing those actions on the wksht object? i.e. wksht.cells or
wksheet.range, etc.?

"Darrin Henshaw" wrote:

At least I don't get the error now. But what does happen is that the
actions I need to perform are only happening in the activeworksheet, not
any of the others. Here's an update to the code:

Dim wksht As Worksheet
Application.ScreenUpdating = False

For Each wksht In ActiveWorkbook.Worksheets

Point to note, this same thing happens if I use Sheets, instead of the
ActiveWorkbook. Thanks.

*** Sent via Developersdex http://www.developersdex.com ***



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 38
Default For Each Next

I guess the actions are on the wksht.Cells object, since I'm inserting a
set number of rows.



*** Sent via Developersdex http://www.developersdex.com ***
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,337
Default For Each Next

this should do it
Sub insertrowsinallsheets()
For Each w In Worksheets
w.Cells(1, 1).Resize(3, 1).EntireRow.Insert
Next
End Sub

--
Don Guillett
SalesAid Software

"Darrin Henshaw" wrote in message
...
I guess the actions are on the wksht.Cells object, since I'm inserting a
set number of rows.



*** Sent via Developersdex
http://www.developersdex.com ***


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



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