Column separator change in VBA

essebteyahmed

New Member
Joined
Feb 7, 2017
Messages
1
Gentlemen,

I have a monthly report that I need to update with fresh data from a CSV file, where the column separator is ";", I changed the parameter in windows (Control Panel/ Region/ Advanced settings/ column seperator), and when I open the CSV file manually, the columns are correctly separated, but when I open the same file using the VBA statement Workbooks.open(), the file opens as if I didn't change the column separator parameter.

Any Ideas?

Thanks
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Welcome to the Board!

Open it using a Text option that allows you to set the delimiter upon Import.
One way is to go to the Data menu, and on the Get External Data ribbon, use From Text. That will invoke the Import Wizard and allow you to use any delimiter you want.
If you want the VBA code for this, simply use the Macro Recorder, and record yourself doing it manually once.
 
Upvote 0
If the file extension is .CSV then I think Excel mandates that the text is delimited by commas. A workaround is to rename (or copy) the file to use a different extension and then use the Workbooks.Open() method making sure you supply the Delimiter parameter appropriately.

WBD
 
Upvote 0
If the file extension is .CSV then I think Excel mandates that the text is delimited by commas.
That is one way, but it is not the only way.
It all depends on how you open the file. If you just try to use the Open command, you will experience that behavior. But if you open it using the method I described, you can import it without having to rename it.
 
Upvote 0

Forum statistics

Threads
1,215,063
Messages
6,122,927
Members
449,094
Latest member
teemeren

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