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 :
[TABLE="width: 182"]
<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>[TR]
[TD="width: 71, bgcolor: #BDD7EE"]ETD[/TD]
[TD="width: 93, bgcolor: #BDD7EE"]Original ETA to Final Destination[/TD]
[TD="width: 79, bgcolor: #BDD7EE"]Current ETA to Final Destination
[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent, align: right"]43364[/TD]
[TD="bgcolor: transparent, align: right"]43416[/TD]
[TD="bgcolor: transparent, align: right"]43416[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent, align: right"]43364[/TD]
[TD="bgcolor: transparent, align: right"]43416[/TD]
[TD="bgcolor: transparent, align: right"]43416
[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent, align: right"]43386[/TD]
[TD="bgcolor: transparent, align: right"]43417[/TD]
[TD="bgcolor: transparent, align: right"]43415
[/TD]
[/TR]
</tbody>[/TABLE]


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

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"

Forum statistics

Threads
1,223,236
Messages
6,170,917
Members
452,366
Latest member
TePunaBloke

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