+ Reply to Thread
Results 1 to 4 of 4

Save File As Cell Value (loop through folder)

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    04-06-2009
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    103

    Save File As Cell Value (loop through folder)

    Hi there

    I'm wanting a macro which will loop through a folder (F:\test folder) and open each file
    I would then like to rename the file based on the contents of Sheet2 cell D3 (d3 is simple the name of a region, eg, "midlands")

    The file should then be saved to "F:\new folder" and the workbook closed down
    The macro will then look at the next file in the folder and repeat the process

    This may be a problem - some files are .xls and others are .xlsm

    Any ideas? I've found similar macros however have not been able to adapt them at all

    Thanks

  2. #2
    Valued Forum Contributor
    Join Date
    03-14-2012
    Location
    Arizona USA
    MS-Off Ver
    Excel 2000/2007
    Posts
    408

    Re: Save File As Cell Value (loop through folder)

    Do you know all the filenames before you start?

  3. #3
    Valued Forum Contributor
    Join Date
    05-21-2009
    Location
    Great Britain
    MS-Off Ver
    Excel 2003
    Posts
    550

    Re: Save File As Cell Value (loop through folder)

    Have a look at/search for the VBA Dir function to loop through the files. Use the Macro Recorder to get code for opening workbooks and saving as. Use string functions like InstrRev and Mid to handle the different file extensions.

  4. #4
    Forum Contributor
    Join Date
    04-06-2009
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    103

    Re: Save File As Cell Value (loop through folder)

    Hi Dennis,

    Unfortunately I would not know all the files which are in the folder to be renamed.

    Any ideas?

+ 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