![]() |
How to Cycle through open workbooks
How do I cycle through the open workbooks and perform a vba script on each
one? |
How to Cycle through open workbooks
See the sample For Each-Next loop below:
Sub cycle() Dim a As Object For Each a In Workbooks 'do whatever you want to do here a.Worksheets(1).Range("A1").Value = 1 Next End Sub "Buster" wrote: How do I cycle through the open workbooks and perform a vba script on each one? |
How to Cycle through open workbooks
Dim a As Object
Better to declare 'a' As Workbook since the Workbooks collection contains only Workbooks. -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "Edwin Tam" wrote in message ... See the sample For Each-Next loop below: Sub cycle() Dim a As Object For Each a In Workbooks 'do whatever you want to do here a.Worksheets(1).Range("A1").Value = 1 Next End Sub "Buster" wrote: How do I cycle through the open workbooks and perform a vba script on each one? |
All times are GMT +1. The time now is 10:00 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com