I'm trying to export data from an excel file to a csv file using a macro. It works fine except for the part where the date format from the excel file (dd-mmm-yyyy) gets changed to (dd-mmm-yy) in the csv file. I would like to keep the date format as (dd-mmm-yyyy) in the csv file as well.
Could anyone please help me? A part of the code that writes the data to the csv file is
c1 = 2
Dim tempDate As String
Dim tempDate2 As String
tempDate = Format(Sheets("Source").Cells(c1, 2).value, "dd-mmm-yyyy")
tempDate2 = Format(Sheets("Source").Cells(c1, 3).value, "dd-mmm-yyyy")
txtfile.WriteLine (Sheets("Source").Cells(c1, 1).value & sSep & tempDate & sSep & _
tempDate2 & sSep & Sheets("Source").Cells(c1, 4).value & sSep & _
temp1 & sSep & Sheets("Source").Cells(c1, 6).value & sSep & Sheets("Source").Cells(c1, 7).value & sSep & _
Sheets("Source").Cells(c1, 8).value)
c1 = c1 + 1