ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Loop Thru Worksheets (https://www.excelbanter.com/excel-programming/382268-loop-thru-worksheets.html)

Tinkerbell[_2_]

Loop Thru Worksheets
 
Hello
I have a workbook with several worksheets that contain the same rows
and same colums that I run a macro on each sheet one sheet at a time
the macro does the same thing to each sheet It works just fine .
All I need is to have the Macro run on every sheet in the workBook I
know it can be done but I cant get anything to work for Me.
Can anyone Help me with something I can use to loop thru the
worksheets?
Thanks
OKE DOKE


Don Guillett

Loop Thru Worksheets
 
for each ws in sheets
msgbox ws.name
next ws

--
Don Guillett
SalesAid Software

"Tinkerbell" wrote in message
oups.com...
Hello
I have a workbook with several worksheets that contain the same rows
and same colums that I run a macro on each sheet one sheet at a time
the macro does the same thing to each sheet It works just fine .
All I need is to have the Macro run on every sheet in the workBook I
know it can be done but I cant get anything to work for Me.
Can anyone Help me with something I can use to loop thru the
worksheets?
Thanks
OKE DOKE




Doug Glancy

Loop Thru Worksheets
 
Tinkerbell,

Sub test()
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
' your code here
Next ws
End Sub

hth,

Doug

"Tinkerbell" wrote in message
oups.com...
Hello
I have a workbook with several worksheets that contain the same rows
and same colums that I run a macro on each sheet one sheet at a time
the macro does the same thing to each sheet It works just fine .
All I need is to have the Macro run on every sheet in the workBook I
know it can be done but I cant get anything to work for Me.
Can anyone Help me with something I can use to loop thru the
worksheets?
Thanks
OKE DOKE





All times are GMT +1. The time now is 04:13 PM.

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