-
Date Time copy paste not including time
OK, this is probably a simple fix but I have been banging my head on this one for a while now.
I have a CSV file that I import into a sheet and run a text to columns process to slit it up. One column has date and one has time and all the data appears to be there.
Date column B = 41289
Time Column C = 0.676793981481482
When I enter a formula to combine them in column D like =B1+C1 I get the proper value of 41289.676794
The problem I have is when I copy the entire column D and paste as values in column E in VBA it always drops the time from the number (EI 41289.0)
[VBA]
Range("E1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks_:=False, Transpose:=False
[/VBA]
What I am doing wrong here? I have tried number formating, paste as valueandnumberformats, etc.
Works fine manually but in code it always drops the time?
-
Works ok for me. Make a short example file and attach for us to troubleshoot.
[VBA] Range("D1").Copy
Range("E1").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False[/VBA]
-
I believe that should work too.
But...
You could also try such solution.
Select range to copy and run this macro:[vba]Sub AAA()
Dim vArr As Variant
If TypeName(Selection) <> "Range" Then Exit Sub
vArr = Selection
If Selection.Count = 1 Then
Range("E1") = vArr
Else
Range("E1").Resize(UBound(vArr), UBound(vArr, 2)).Value = vArr
End If
End Sub[/vba]
Artik
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules