+ Reply to Thread
Results 1 to 2 of 2

Macro to format multiple files from one directory

  1. #1
    Registered User
    Join Date
    03-16-2005
    Posts
    1

    Macro to format multiple files from one directory

    I need to change the format of a large number of spreadsheets that are all in one directory.

    Is there a way to automatically open each file in turn - run a macro to make formatting changes, save and close the spreadsheet and open the next one.

    Ideally I want to avoid having to manually type in a a long list of filenames.

    In the past I was able to do this using an array but do not recollect what I actually did.

    Please help.

    Regards


    Sandy

  2. #2
    Valued Forum Contributor mudraker's Avatar
    Join Date
    11-10-2003
    Location
    Melbourne, Australia
    Posts
    3,983
    sxv102

    Sub FormatBooks()
    Dim sDir As String
    'delete duplicate report files
    sDir$ = Dir("c:\Temp\*.xls")
    Do
    If sDir = "" Then
    Exit Do
    Else
    Workbooks.Open Filename:="c:\Temp\" & sDir
    your code to format here
    End If
    sDir = Dir
    Loop

    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1