B Buster Nov 19, 2004 #1 How do I cycle through the open workbooks and perform a vba script on each one?
G Guest Nov 19, 2004 #2 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
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
C Chip Pearson Nov 19, 2004 #3 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
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