Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 425
Default for each sheet in workbook

how to perform macro on each sheet in workbook.
(except first worksheet = "master data")

I've tried the subs below but only worked on one sheet.

Public Sub DoToAll()
Dim ws As Worksheet
For Each ws In Worksheets
Application.Run "filldown"
Next
End Sub

Sub loopthroughanddo()
x = Sheets("master data").Index
For Each sh In ThisWorkbook.Sheets
If sh.Index x Then
Application.Run "filldown"
End If
Next
End Sub
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default for each sheet in workbook

A lot depends on what filldown does....it needs to know what the current ws
object is, so pass it to it. This example code copies cell A1 of every
sheet and fills it down column A to match column B.


Public Sub DoToAll()
Dim ws As Worksheet
For Each ws In Worksheets
If ws.Name < "master data" filldown ws
Next ws
End Sub

Sub filldown(shtWS As Worksheet)
shtWS.Range("A1").Copy shtWS.Range("A2:A" & _
shtWS.Cells(Rows.Count, 2).End(xlUp).Row)
End Sub


HTH,
Bernie
MS Excel MVP


"J.W. Aldridge" wrote in message
...
how to perform macro on each sheet in workbook.
(except first worksheet = "master data")

I've tried the subs below but only worked on one sheet.

Public Sub DoToAll()
Dim ws As Worksheet
For Each ws In Worksheets
Application.Run "filldown"
Next
End Sub

Sub loopthroughanddo()
x = Sheets("master data").Index
For Each sh In ThisWorkbook.Sheets
If sh.Index x Then
Application.Run "filldown"
End If
Next
End Sub


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
Help needed: Getting all sheet setup data from one workbook toanother workbook Lostguy Excel Programming 1 July 8th 08 02:43 PM
Copy rows from multiple workbook into a different workbook (sheet) Yossy Excel Programming 19 May 11th 08 12:34 AM
Copying data from workbook/sheets to another workbook/sheet yukon_phil Excel Programming 0 July 26th 06 07:33 PM
Select sheet tabs in workbook & save to separate workbook files stratocaster Excel Worksheet Functions 2 March 1st 06 03:35 PM


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

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"