I am trying to disable excel to convert normail string like 1-2 to date 1/2/2021, I know there is no default settings to disable this behavior.
I am wondering whether there is any event to be fired before converting or any automatically way to convert back.
Any possible way is acceptable.
I am glad to implement through VBA
, Excel VSTO Addin
or excel-dna
.
CodePudding user response:
Using VBA, set the column(s) that will contain the dates to 'text'.
ie Columns("A:A").NumberFormat = "@"
If you are opening the file from within Excel, use the 'import wizard' and make sure the date columns are set to 'text'.
An alternative method is to update the data to include an apostrophe before the date but that is getting desperate.
CodePudding user response:
There is no way to achieve this on double click in Explorer (to open the CSV in Excel).
The only alternatives where you have control what happens are:
Import using VBA or Power Query (or the legacy import wizard).
For examle: Import CSV without data being formatted to dates and numbers