Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
for each sheet in workbook
Why not just use the name
If sh.name<"master data" Then -- Don Guillett Microsoft MVP Excel SalesAid Software "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 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Help needed: Getting all sheet setup data from one workbook toanother workbook | Excel Programming | |||
Copy rows from multiple workbook into a different workbook (sheet) | Excel Programming | |||
Copying data from workbook/sheets to another workbook/sheet | Excel Programming | |||
Select sheet tabs in workbook & save to separate workbook files | Excel Worksheet Functions |