• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Rename Output CSV file based on file name

deannaed

New Member
Hi Everyone

I have a spreadsheet from which the last action I execute is to export one of the sheets as a CSV.

I am currently saving that CSV using the following code.


Code:
ActiveWorkbook.SaveAs Filename:= _
        "C:\x\upload.csv", FileFormat:=xlCSVMSDOS, _
        CreateBackup:=False
    ActiveWorkbook.SaveAs Filename:= _
        "C:\x\upload.csv", FileFormat:=xlCSVMSDOS, _
        CreateBackup:=False



The CSV currently saves as "Upload.csv"
All is fine there except that I wish to save the CSV as the current file name (with an additional character).
Explanation: If the current spreadheet is "A1234", I would like to save my csv as "QA1234". The "Q" will be constant.
A3285 should become QA3285
A4568 should become QA4568
A9874 should become QA9874
A5456 should become QA5456


I hope that one of our valued members will be able to assist.

Thank You In Advance
 
Hi,
Try
Code:
ThisWorkbook.SaveAs Filename:= _
"C:\x\" & "Q" & Left(ActiveWorkbook.Name, InStr(ActiveWorkbook.Name, ".") - 1) & ".csv", FileFormat:=xlCSVMSDOS
 
Back
Top