Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Excel - VBA sheet export to csv and leave original file alone

Excel - VBA sheet export to csv and leave original file alone

Excel - VBA sheet export to csv and leave original file alone

Hi All;

I have a small problem with exporting a specific sheet to a csv file. While the sheet exports correctly, the hosting file changes name and sets itself to a csv file which causes a lot of problems.

I recorded a macro in an effort to get some starter code, but I don't think it understands specifically what to do.

On a sheet called "Menu" the macro is pulling variables in specific text boxes. The csv file is correctly saving to that location, so there isn't an issue there. What I think is going wrong is the ActiveWorkbook.SaveAs section of code. how can I change that the the specific sheet called "data"?

CODE -->

file = Worksheets("Menu").file_name_txt_box
folder = Worksheets("Menu").export_location_text_box
export_data = ActiveWorkbook.Sheets("data").Select

ChDir folder
ActiveWorkbook.SaveAs file, xlCSV, CreateBackup = False 



RE: Excel - VBA sheet export to csv and leave original file alone

ActiveWorkbook.Sheets("data").Copy will create a copy of the sheet in new workbook. You can process this workbook without interacting with original file. Copy method does not return a copy, you can pick it either as ActiveWorkbook, or searching in Workbooks collection.


Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close