ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   For Each Next (https://www.excelbanter.com/excel-programming/329157-each-next.html)

Darrin Henshaw

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 ***

Don Guillett[_4_]

For Each Next
 
try in worksheets or in sheets

--
Don Guillett
SalesAid Software

"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.

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



Danny@Kendal

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



Darrin Henshaw

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 ***

Charlie

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 ***


Darrin Henshaw

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 ***

Don Guillett[_4_]

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 ***




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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com