0

Hi I am writing a VBA Macro to read data from a web site and dump it into a file so a third party program can process the data from this csv file, however I have noticed that the date column on excel seems fine, but when I write the full range of dates and its values to a csv file the dates are surrounded by "#" (hash) characters. I have researched and I have learned that this is a way excel identifies this data as dates and automatically display them properly on the cells, however the program that process the csv files does not require (or understands) the # date format, is there a way to remove the # characters from the date?, or some conversion that I can apply to the date column before I write it to the file so it does not include these characters on the date?

PS: I require a mm/dd/yyyy format on the date value

Thanks!

  • Its a known issue with excel. See http://office.microsoft.com/en-001/excel-help/stop-automatically-changing-numbers-to-dates-HA102809473.aspx or http://stackoverflow.com/questions/165042/stop-excel-from-automatically-converting-certain-text-values-to-dates – chiliNUT Oct 01 '14 at 05:31

1 Answers1

0

I suppose you use the VBA Write command. Try Print instead.

Fratyx
  • 5,717
  • 1
  • 12
  • 22
  • I did try this, however the output file is not including " " on the strings (which I need to be included on string fields), and separation from cells are written as "tabs" instead of ",", so the file is not in the proper format, maybe if is there a way to replace the "tabs" for "," this could help... Thanks! – Charlie Contreras Oct 02 '14 at 00:09
  • You can format the date `dt` by using `Format(dt, "mm/dd/yyyy")` and print the result string to get rid of the "#". – Fratyx Oct 02 '14 at 05:08