I'm collecting data from many workbooks. The problem is, in every document the date format is not consistent: 16/01/2015 2015-01-06 24.03.2014
What I want to achieve is "YYYY-MM-DD" format. In my code I've a case which responsible to clear the date columns. Now I'm getting desperate and I added stupid amount of date formatting to the code, but no changes when it comes to the dotted format (one with bold above). Even If I select manually the column and change the format type, or copy the values to a .txt file then copy back to the original sheet, also tried with a new WorkBook, but nothing happened. Why is it impossible to change the date values in this few instances? Any help would be appreciated. Here is the code:
        Case 6:
    sourceWorkbook.Activate
    sourceWS.Activate
    sourceWS.Columns(i).Select
    Selection.NumberFormat = "YYYY-MM-DD;@"
    sourceWS.Range(Cells(2, i), Cells(lastrw, i)).NumberFormat = "YYYY-MM-DD;@"
        For j = startRow To lastrw Step 1
            'Assign the header to the first row
            NewWorksheet.Cells(1, i) = sourceWS.Cells(startRow, i).Value
            On Error Resume Next
                textToFormat = CStr(sourceWS.Cells(j, i).Value)
                d = CDate(textToFormat)
                finalDate = Format(textToFormat, "YYYY-MM-DD")
                NewWorksheet.Cells(j - adjustRows, i) = finalDate
                'This error handler purpose to handle the header name!
                If Err Then
                    NewWorksheet.Cells(j - adjustRows, i) = textToFormat
                End If
            On Error GoTo 0
        Next j
        Set fckFormat = NewWorksheet.Columns(i)
        fckFormat.NumberFormat = "YYYY-MM-DD;@"
        NewBook.Activate
        NewWorksheet.Activate
        NewWorksheet.Columns(i).Select
        Selection.NumberFormat = "YYYY-MM-DD;@"
 
     
    