+ Reply to Thread
Results 1 to 3 of 3

Macro to save sheet as CSV using a dynamic file name and file path

  1. #1
    Registered User
    Join Date
    10-18-2012
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    8

    Macro to save sheet as CSV using a dynamic file name and file path

    Hi Guys,

    I want a macro to save a sheet ( called 'Export')in a workbook as a CSV. I have another sheet called 'Setup' which has two cells on it, one specifies the file name of the CSV and the other specify's the path - I need the macro to reference to these cells rather than hard coding the filename and path into the macro.

    I want to attach the macro to a button on a control sheet in the workbook (I know how to do this bit)

    Thanks!!!!!

  2. #2
    Forum Contributor
    Join Date
    10-18-2012
    Location
    Telford, England
    MS-Off Ver
    Excel 2010 (2003)
    Posts
    294

    Re: Macro to save sheet as CSV using a dynamic file name and file path

    Define names for the path and name cell, or replace them in the following with Range("rc") or whatever...

    set ws = activeworkbook.sheets("Setup")
    ' export to separate document
    sheets(Export").move
    ' save as CSV with name and path
    activeworkbook.saveas ws.myPath & ws.myFile,xlCSV
    ' close and return to original workbook
    activeworkbook.close false

  3. #3
    Registered User
    Join Date
    04-15-2013
    Location
    Wisconsin, USA
    MS-Off Ver
    Excel 2010
    Posts
    2

    Re: Macro to save sheet as CSV using a dynamic file name and file path

    Brnbaker, I'd like to do this also. In the sample code above I fail to understand how ws.myPath and ws.myFile are set to values from a Range("rc") in another worksheet. (Unfortunately, I am new to adding macros to a spreadsheet, but the problem described by chris.tinta is very similar to a problem I'm trying to solve.) Thanks.

+ 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