LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
Kim Kim is offline
external usenet poster
 
Posts: 12
Default More efficient way for macro to run on multipe files?

Hi all,

Each month one of systems exports a bunch of excel documents into various
directories. I am writing a macro that will automatically format each
file. I've attached part of my code below. My question is, is there a
more efficient way for the macro to open each file and format it without me
having to list the path of each file. Keep in mind that I have about 50
files (hence 50 file paths). I'm still a newbie so I have lots to learning
about programming. Any help is appreciated.

Thanks Kim


Sub FormatOpay()
Application.ScreenUpdating = False
Application.DisplayAlerts = False

Dim OPAYPath As String
Dim OPAYMonth As String

'Establish Directory Path
OPAYPath = "C:\VBA Test\2007\"
OPAYMonth = "03" ' each month this number will change

On Error Resume Next

'Open Workbooks to be formatted
Workbooks.Open Filename:=OPAYPath & "39385\MEOPGL" & OPAYMonth & ".xls"
Call OpayFormat

Workbooks.Open Filename:=OPAYPath & "34335\MSOPGL" & OPAYMonth & ".xls"
Call OpayFormat

Workbooks.Open Filename:=OPAYPath & "34392\MTOPGL" & OPAYMonth & ".xls"
Call OpayFormat
' I will have about 47 more file paths; the OpayFormat macro formats and
automatically closes each file once it is formatted.

End Sub


 
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
Lookup value with multipe Results John Excel Worksheet Functions 5 February 24th 09 11:37 PM
More efficient macro help Dean[_8_] Excel Programming 4 February 2nd 07 03:44 PM
Multipe file transfer using FTP HenryV Excel Programming 1 May 6th 06 02:52 AM
recently used files, more efficient Patricia Shannon Excel Discussion (Misc queries) 0 April 4th 06 11:33 PM
VBA - Efficient Macro ajocius[_17_] Excel Programming 3 August 3rd 05 12:34 PM


All times are GMT +1. The time now is 12:06 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"