VBA deletes time/date formatting

Mehow

New Member
Joined
Feb 23, 2018
Messages
15
Hi all,

I've got macro that does some filtering for me - the problem is pulling the data from sheet1 to sheet2 removes data formatting

example :
ETDOriginal ETA to Final DestinationCurrent ETA to Final Destination
433644341643416
433644341643416
433864341743415
<colgroup><col width="71" style="width: 53pt; mso-width-source: userset; mso-width-alt: 2596;"> <col width="93" style="width: 70pt; mso-width-source: userset; mso-width-alt: 3401;"> <col width="79" style="width: 59pt; mso-width-source: userset; mso-width-alt: 2889;"> <tbody> </tbody>


Code:
Sub sort()
   
    Worksheets("Filtered").Range("A2:AZ9999").Clear

    
    Dim shSource As Worksheet
    Dim shDestination As Worksheet
    
    Set shSource = Sheets("Control")    'Source worksheet
    Set shDestination = Sheets("Filtered")    'Destination worksheet
    
    Application.ScreenUpdating = False
                
    'Autofilter column x for "value"
    shSource.UsedRange.AutoFilter Field:=4, Criteria1:=Array("gate out", "sailing", _
                                    "discharged", "arrived", _
                                    "x", "y", _
                                    "z", "aa"), _
                    Operator:=xlFilterValues
    ' Copy filtered data from columns a:z
    shSource.UsedRange.Columns("A:Z").Offset(1).Copy
    
    'Paste the filtered data to Sheet "x"  column Dx
    shDestination.Range("A" & Rows.Count).End(xlUp).Offset(1).PasteSpecial xlPasteValues
    Application.CutCopyMode = False
    
    'Clean up
    shSource.AutoFilterMode = False
    Application.Goto shDestination.Range("A1")
    Application.ScreenUpdating = True
    MsgBox "Completed"
    
End Sub


Any idea why?
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).

Forum statistics

Threads
1,215,045
Messages
6,122,840
Members
449,096
Latest member
Erald

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top