VBA to Save Sheet as CSV New Workbook

garciausmc

New Member
Joined
Nov 20, 2013
Messages
12
Hello. Looking for a VBA to select all cells with data (only cells with data) and copy it from a sheet from "workbook a" and paste into a new "workbook b". Then save file as CSV and give users the ability to enter their own file name and where they save it. Is this doable? Any help would be extremely appreciated!
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
I am curious.
* How is your data set up on the worksheet?
* What is the purpose of selecting only cells with data?
* What happens to those cells with no data?
* How do you want your output in terms of column / row?
 
Upvote 0
You should state how you want to select data. Are you going to select manually or automatically? If automatically, then you should post how your data sheet looks like.

If you haven't, try install XL2BB (icon there) to copy and paste the sheet. This way helpers out there can copy and paste your sheet. No need to retype your sample which most likely just ignore your question. :)
 
Upvote 0
I am curious.
* How is your data set up on the worksheet?
* What is the purpose of selecting only cells with data?
* What happens to those cells with no data?
* How do you want your output in terms of column / row?
Hello
-The sheet is using a macro to pull data from another sheet. Users will download a report from one application, copy the data from that report, and paste it into the workbook. I built a macro to extract the data from that report and format it correctly so they can use it to upload it into a different application to create a request for something.
-I won't know the number of rows each individual user will put into the sheet that I am trying to save as CSV. It will be different every time and they will start over every time.
-I have a macro that trims all lines below the last row with data on the sheet. Sometimes, the application that we upload to will error if there are empty rows in the CSV that has/used to have data; even if it's phantom data.
-The output should just be pasted into cell A1 in a new workbook. This new workbook would then be saved as CSV as the file name and location chosen by the user.

I will note, the upload sheet will always have the same number of columns but there will be a different number of rows each time. No more than probably 500 rows at the max. Most of them will be like the image I uploaded. Anywhere from 1-30 rows.
I can't use the upload mini-sheet feature so here is a picture of the sheet I would like to export as CSV. Sheet is titled "Upload".
 

Attachments

  • Upload File Example Snippit.png
    Upload File Example Snippit.png
    95.3 KB · Views: 8
Upvote 0
More importantly, how the source data looks like.
 
Upvote 0

Forum statistics

Threads
1,214,979
Messages
6,122,551
Members
449,088
Latest member
davidcom

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top