pastespecial with time date and numbe formats

rjmdc

Well-known Member
Joined
Apr 29, 2020
Messages
672
Office Version
  1. 365
Platform
  1. Windows
hi
i lose my date/time and dollar cformats with the copy paste
what can i do to fix it?

Sub Export
()

Call RefreshPQActiveWorkbook

Call WSUnProtect(ActiveSheet)

Dim wb As New Workbook
Dim SaveFolder As String: SaveFolder = "M:\all\Workbook\"
Dim FileName As String
Dim FileDateTime As String: FileDateTime = Format(Now, "m-d-yy hh-mm")

With ActiveWorkbook.Worksheets("Expenses")
FileName = GetNewDescription(Worksheets("Expenses").Cells(1, "B")) & " " & Format(Worksheets("Expenses").Cells(2, "B"), "m_d_yyyy")
Set tbl = .ListObjects(1)
tbl.Range.Copy
End With

Set wb = Workbooks.Add
wb.Activate
wb.Sheets(1).Range("A1").PasteSpecial xlPasteAll
Selection.Columns.AutoFit

FullFileName = FileName & " (" & FileDateTime & ").xlsx"

'Save and Close New WB
wb.SaveAs SaveFolder & "\" & FullFileName, xlOpenXMLWorkbook
wb.Close SaveChanges:=False

'Back to Main WB
ThisWorkbook.Activate

Call FIFeeEmail

'Inform User
MsgBox "File Export Complete", vbInformation

End Sub
[/CODE]
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
This should work:
VBA Code:
wb.Sheets(1).Range("A1").PasteSpecial xlPasteValuesAndNumberFormats

I actually put the Paste Values with Number formatting button on my Quick Access Toolbar, I think in 90% of cases where people use paste values they would have been better off to use this option.
 
Upvote 0

Forum statistics

Threads
1,214,908
Messages
6,122,187
Members
449,071
Latest member
cdnMech

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