ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Run a Macro within a Macro (https://www.excelbanter.com/excel-programming/425580-run-macro-within-macro.html)

elf27

Run a Macro within a Macro
 
I've got a public sub that updates information on a specific worksheet called
SyncAESheet. I want to run that macro on each page in the workbook.
Unfortunately, it's only running once (on the current worksheet). What am I
doing wrong?

-------

Public Sub ProcessData()
Dim w As Worksheet
Application.ScreenUpdating = False

For Each w In ActiveWorkbook.Sheets
SyncAESheet
Next


Application.ScreenUpdating = True

End Sub

Jacob Skaria

Run a Macro within a Macro
 
You need to activiate the current workbook
Use w.Activate within the loop..
Or pass w as a argument to your subroutine

If this post helps click Yes
---------------
Jacob Skaria


elf27

Run a Macro within a Macro
 
Thanks, Jacob!

"Jacob Skaria" wrote:

You need to activiate the current workbook
Use w.Activate within the loop..
Or pass w as a argument to your subroutine

If this post helps click Yes
---------------
Jacob Skaria



All times are GMT +1. The time now is 02:24 PM.

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