Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Perform action on every workbook in a directory


Hello everyone,

All of my workbooks in a directory have the same format. As it stands
now, I open each one manually, and have my code extract the data from a
sheet and aggregate it on the appropriate sheet of my report file.

All I am looking to do is open each workbook, perform my macro, close
the work book and open the next. I figure to do this correctly, the
macro would have to count the workbooks in the directory (there are
51), and from 1-n, open work book, call my macro, close workbook, next
n.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Perform action on every workbook in a directory


Sub a()
Dim wkb As Workbook
Dim strPath As String
Dim strFile As String

strPath = "C:\myfiles\" your path
strFile = Dir(strPath & "*.xls")
Do While strFile < ""
Set wkb = Workbooks.Open(strPath & strFile)
'do your bits
wkb.Close savechanges:=True
strFile = Dir()
Loop
MsgBox "done"
End Sub

regards


--
tony h
------------------------------------------------------------------------
tony h's Profile: http://www.excelforum.com/member.php...o&userid=21074
View this thread: http://www.excelforum.com/showthread...hreadid=509000

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Perform action on every workbook in a directory


Thats perfect, thank you very much.


--
Btibert
------------------------------------------------------------------------
Btibert's Profile: http://www.excelforum.com/member.php...fo&userid=8559
View this thread: http://www.excelforum.com/showthread...hreadid=509000

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
Perform action if value in cell - conditional VB stmt Studebaker Excel Discussion (Misc queries) 2 February 29th 08 06:34 PM
Compare two sheets and perform action routine wayliff[_9_] Excel Programming 2 January 16th 06 08:28 PM
How to 'Click and then perform action' chris100[_7_] Excel Programming 14 August 2nd 05 02:57 PM
How to perform action in all worksheets Sethaholic Excel Programming 6 July 11th 05 07:44 PM
Perform action when cell is clicked Jason[_26_] Excel Programming 3 October 4th 03 06:08 PM


All times are GMT +1. The time now is 08:14 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"