Convert all .csv files in a folder to .txt format.

TheHack22

Board Regular
Joined
Feb 3, 2021
Messages
121
Office Version
  1. 365
Platform
  1. Windows
  2. Mobile
Hi All,

I have numerous files in a folder that's in .csv format. I would like to convert all the .csv files to .txt format.

Can someone please help me with a VBA code to accomplish this, if this is possible?

Thanks
Imran
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
You need to provide more details.
There are many different "txt" file formats (i.e. fixed-width space delimited, tab-delimited, etc).
So we need to know exactly what kind of txt files you need.
Is it fixed-width or delimited?

If fixed-width, we need to know the size of each field.

If delimited, we need to know what the delimiter is.

And does the file require any sort of text qualifiers?
 
Upvote 0
You need to provide more details.
There are many different "txt" file formats (i.e. fixed-width space delimited, tab-delimited, etc).
So we need to know exactly what kind of txt files you need.
Is it fixed-width or delimited?

If fixed-width, we need to know the size of each field.

If delimited, we need to know what the delimiter is.

And does the file require any sort of text qualifiers?
 
Upvote 0
Hi Joe,

Thanks for your question. It's delimited - comma. The text qualifier is also a comma.

Imran
 
Upvote 0
Thanks for your question. It's delimited - comma. The text qualifier is also a comma.
I am not asking you what the current format is. I am asking what format you want to convert it to.
"Text" does not really tell us very much, as that can mean many different things.

Also, commas cannot be text qualifiers. Text qualifiers are used to surround text.
For example, if you have text that may have commas in it, you would need some way to differentiate commas that are delimiters versus commas that are literal text.
Quite commonly, double-quotes are used as Text Qualifiers, meaning that any commas found between two sets of double-quotes are to be treated as literal text, and not delimiters.

For example, let's that that you have data like the following:
NameAddressAge
Jane Smith1 Main St, New York, NY 11111
24​
Bill White, Jr.15 River Way, Miami, FL 22222
37​

In a CSV file with text qualifiers, it might look something like this:
"Jane Smith","1 Main St, New York, NY 11111",24
"Bill White, Jr.","15 River Way, Miami, FL 22222",37

(color coded to show each piece).

Notice how all commas inside of double-quotes are literal text, and the ones outside are delimiters.

Back to the original question, it might be helpful for you to post a small sample of your CSV data, and what you want your expected result to look like.
Just be sure to remove/dummy-up any sensitive/personal data.
 
Upvote 0

Forum statistics

Threads
1,214,857
Messages
6,121,948
Members
449,056
Latest member
FreeCricketId

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