Does anyone happen to know if there is a token I can add to my csv for a certain field so Excel doesn\'t try to convert it to a date?
I\'m trying to write a .csv fil
I made this vba macro which basically formats the output range as text before pasting the numbers. Works perfect for me when i want to paste values such as 8/11, 23/6, 1/3 etc. without Excel interpreting them as dates.
Sub PasteAsText()
' Created by Lars-Erik Sørbotten, 2017-09-17
Call CreateSheetBackup
Columns(ActiveCell.Column).NumberFormat = "@"
Dim DataObj As MSForms.DataObject
Set DataObj = New MSForms.DataObject
DataObj.GetFromClipboard
ActiveCell.PasteSpecial
End Sub
I'm very interested in knowing if this works for other people as well. I've been looking for a solution to this problem for a while, but I haven't seen a quick vba solution to it before which didn't include inserting ' in front of the input text. This code retains the data in its original form.