Batch process csv files

Suryaprakash

New Member
Joined
Aug 1, 2011
Messages
41
Hi Folks:

I have several files in D:\Folder3 and I wish to delete column N:P and rows 15:38 and then save the files as .xls in the same folder. All files have only one sheet and I use excel 2000. Any solution?

Thanks
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
Recording a macro is not a problem but the real problem for me is in naming the file. The file should take the name of the same (ACTIVE) file. For example, Ashok.csv should become Ashok.xls, Vijay.csv should become Vijay.xls and so on. When I record the macro for one file, say Ashok.csv and name it as Ashok.xls, the subsequent files also take the same name that is, Ashok.xls when I loop the files.

I want a syntax that the SaveAs should take the name of the ACTIVE FILE. Looping the files will not be a problem as I have got a macro for that. Putting commands for deletion of columns and rows is also not a problem. The real problem is naming the output file. Hence this request.

Regards.
 
Upvote 0
The real problem is naming the output file.

But you use the Left function to take all but 4 characters out of the file name. So basically everything except the .csv at the end. Then add (hardcoded for instance):

... & ".xls"
 
Upvote 0
Hi Wigi:

I tried your suggestion but could not do it right. In fact, I am not very conversant with VBA and trying to learn step by step by trial and error.

Could you give me the complete sentence for saveas command.
 
Upvote 0
What is the SaveAs that you now have?

Did you step through the macro with F8 and inspecting the contents of variables? You can also use Msgbox or Deug.rint to output the contents of variables on screen.
 
Upvote 0

Forum statistics

Threads
1,220,965
Messages
6,157,119
Members
451,398
Latest member
rjsteward

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