0

I have a MAIN.xlsm with a macro called "open_input_workbook" which opens a CSV file.

The problem is that when I open the file using that macro, the file doesn't respect the columns, I'll show you with some screenshots:

input.csv open doing Double-Click on it:

opened with double click

input.csv open with the macro:

opened with macro

Macro Code:

Sub Open_input_Workbook()
  Workbooks.Open "C:\input.csv"
End Sub

Any help is welcome.

Thank you for your time

4
  • 1
    You need to set the delimiter to ; the default is , on a csv. Commented Jun 5, 2020 at 12:12
  • Tried with the next code: Workbooks.Open "C:_Disco_local_Proyectos\AppMacroExcel\input.csv", Delimiter = ";" but still doing the same @Warcupine Commented Jun 5, 2020 at 12:19
  • You might need to save it as a .txt then reopen it with openworkbooks. You can try to use format = 4 but I think the formatting of the csv is already messed up. Commented Jun 5, 2020 at 12:26
  • Try using Workbooks.Open "C:\input.csv", Local:= True Commented Jun 5, 2020 at 13:55

1 Answer 1

1

try to use Workbooks.OpenText instead of the open command. That will allow you to set the delimiter.

https://learn.microsoft.com/en-us/office/vba/api/excel.workbooks.opentext

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.