Importing a csv file from a current folder then save it as an xls file.

yorkshirelad

Board Regular
Joined
Aug 18, 2003
Messages
100
I'm nearly there with a large project but I have two questions which I'd really appreciate some help with...

1) I have a workbook (feedback.xlsm) in a folder (goods) on my desktop

I need a macro to to add to the workbook to import a csv file e.g. sales.csv Destination:=Range("$A$1")). The csv file is in the same folder as the workbook.

I can record the formatting etc but because the macro to import the file needs to work on different pcs - I need to do this this without referencing the full path. (This is to prevent the use of Users\Name\Desktop etc.

2) When I've formatted the content I would then like a macro to save the new file as formatsales_ddmmmyy.xls in the same folder (goods).

Any help would be really appreciated.
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Do I have this correct? You want to SaveAs the workbook that has the code in it, after importing/adding a sheet (the .csv file).
 
Upvote 0
Many thanks for your reply - sorry for the delay I just grabbed a couple of hours sleep :)

I need the first macro initially to import the file. The users would get confused importing and formatting the data.

I then have a macro to format the data.

I need a final macro to Save the new file as formatsales_withTodaysDate.xls in the same location as the original file

It isn't necessary for the new xls file to have any code in, this is purely a data file.
 
Upvote 0
For number 2

Not sure where you want to save it too... but change S path to what you need

sPath = C\desktop\goods

ActiveWorkbook.SaveAs Filename:=sPath & ("formatsales" & Format(Now, "DDMMMYY") & ".xls")
 
Upvote 0
Thanks for your reply.

Its a while since I worked with macro code, could you please lay that out as a macro as when I've tried to add it, it comes up with an error.

Many thanks for your assistance
 
Upvote 0

Forum statistics

Threads
1,224,599
Messages
6,179,827
Members
452,946
Latest member
JoseDavid

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