Microsoft Developer Network > Forums Home > Microsoft ISV Community Center Forums > Visual Basic for Applications (VBA) > Want to save a worksheet as a .csv and name it using data from a specific cell on another worksheet within that workbook.
Ask a questionAsk a question
 

AnswerWant to save a worksheet as a .csv and name it using data from a specific cell on another worksheet within that workbook.

  • Wednesday, October 28, 2009 4:11 PMLT_Lynn Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Trying the following but it is saving the file as fname.csv and not what I want

        Dim fname

    With ActiveWorkbook

    fname = .Worksheets(“Macro").Range("D3").Value & ".csv"

    Sheets("item_mass").Select

    .SaveAs "C:\Documents and Settings\a01760\Desktop\Data_Loads\Prod Trans\130\fname"

    End With

     

        ActiveWorkbook.Save

       

        ActiveWindow.Close

        Sheets("Macro").Select

     

    • Moved byJeff ShanMSFTFriday, October 30, 2009 1:18 AMvba question (From:Visual Basic General)
    •  

Answers

  • Wednesday, October 28, 2009 4:16 PMAndrew B. Painter Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    .SaveAs "C:\Documents and Settings\a01760\Desktop\Data_Loads\Prod Trans\130\fname"



    .SaveAs "C:\Documents and Settings\a01760\Desktop\Data_Loads\Prod Trans\130\" & fname
    It never hurts to try. In a worst case scenario, you'll learn from it.

All Replies