Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default How to Cycle through open workbooks

How do I cycle through the open workbooks and perform a vba script on each
one?


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 94
Default 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?



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default 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?





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
How do I keep result from 1 iteration cycle to use in next cycle? sgl8akm Excel Discussion (Misc queries) 0 July 27th 06 08:28 PM
When I open Excel, workbooks open automatically. How can I stop t Rhealbird Excel Discussion (Misc queries) 2 February 23rd 06 10:08 AM
How do I cycle through all of the open worksheets? DMB Excel Discussion (Misc queries) 0 January 8th 06 11:24 PM
Excel 2003 Workbooks.Open with CorruptLoad=xlRepairFile fails on Excel 5.0/95 file due to Chart, with Error 1004 Method 'Open' of object 'Workbooks' failed Frank Jones Excel Programming 2 June 15th 04 03:21 AM
Workbooks.Open / .Open Text - How do you stop the .xls addition? Dave[_20_] Excel Programming 2 July 31st 03 04:03 AM


All times are GMT +1. The time now is 08:30 AM.

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"