+ Reply to Thread
Results 1 to 8 of 8

save to file dependent on cell

  1. #1
    Forum Contributor
    Join Date
    03-23-2010
    Location
    england
    MS-Off Ver
    Excel 2007
    Posts
    153

    save to file dependent on cell

    hello
    im trying to get a workbook to save to a specific folder and then search within that folder for a folder that is dependant on cell c4

    so if c4 has abcd

    i need it to look in work folder then find the folder that corresponds to cell c4 and then to save to a sub folder within that folder is that possible ?

    thanks

  2. #2
    Forum Contributor
    Join Date
    03-23-2010
    Location
    england
    MS-Off Ver
    Excel 2007
    Posts
    153

    Re: save to file dependant on cell

    folder destination is
    \\workserver\work_file

  3. #3
    Forum Contributor
    Join Date
    03-23-2010
    Location
    england
    MS-Off Ver
    Excel 2007
    Posts
    153

    Re: save to file dependant on cell

    bumping up the page
    please can anyone help?

  4. #4
    Registered User
    Join Date
    12-09-2008
    Location
    Hertfordshire, England
    Posts
    12

    Re: save to file dependant on cell

    Hi, I have included an example below which checks the C: drive for the folder name you enter in cell A1 and then saves the file as 'filename.xls'. Of course, you can change the path and filename to whatever you want.

    Please Login or Register  to view this content.
    By the way, you need to add a reference to the 'Microsoft Scripting Runtime' in VBA for this to work.

    Hope this helps.
    Core 2 Quad Q6600 o/c @ 2.9GHz, 4Gb DDR2 1066MHz, HD5770 1Gb 850MHz, 2 x 750Gb HDD (RAID 0), Benq G2222HDL 22" 1920 x 1080 LED, Win7 Ultimate

    Toshiba Satellite A665-11M, 16" 1366 x 768, i7 720QM 1.6GHz, 4Gb DDR2 1066MHz, GT330M 1Gb, 500Gb HDD, Win7 Home Premium

    Amiga 1200, 3.1 ROM, Blizzard 1230-IV 68030 50MHz CPU, 68882 FPU, 16Mb, 4Gb CF-based HDD, Custom IDE CDROM Drive, Indivision AGA Scandoubler, Custom VGA output, CWB 3.1 ADVSP, Benq G2222HDL 22" 1920 x 1080 LED (720p resolution)

  5. #5
    Forum Contributor
    Join Date
    03-23-2010
    Location
    england
    MS-Off Ver
    Excel 2007
    Posts
    153

    Re: save to file dependant on cell

    hi treacle
    im getting an error with this line
    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    12-09-2008
    Location
    Hertfordshire, England
    Posts
    12

    Re: save to file dependant on cell

    Quote Originally Posted by sdts View Post
    hi treacle
    im getting an error with this line
    Please Login or Register  to view this content.
    As I said in my previous post, you have to add a reference to the Scripting Runtime DLL in order to use the FileSystemObject. To do this, in VBA go to the 'Tools' menu and select 'Reference...', then scroll down to 'Microsoft Scripting Runtime' and tick it then click Ok.

    It should work fine then. (Crosses fingers)

  7. #7
    Forum Contributor
    Join Date
    03-23-2010
    Location
    england
    MS-Off Ver
    Excel 2007
    Posts
    153

    Re: save to file dependant on cell

    hi treacle

    thank you for your patience
    ive done what you said
    but im now getting compile error
    invalid use of me keyword

  8. #8
    Registered User
    Join Date
    12-09-2008
    Location
    Hertfordshire, England
    Posts
    12

    Re: save to file dependent on cell

    That's ok

    The 'Me' keyword is a quick way of referencing the object where the code is located. I placed my code on the sheet with the cell containing the folder name so the 'Me' keyword can be used.

    If your code is anywhere else (in a separate code module maybe), then you need to replace 'Me' with an explict reference to the workbook and sheet. Assuming the sheet you want to pick up the folder name from is called "Sheet1", I have modified the code below:

    Please Login or Register  to view this content.
    Last edited by Treacle; 03-26-2010 at 05:07 AM.

+ 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