View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default Programatically copy cells with dates

Select the original range on sheet1
Give that range a nice format:
mmmm dd, yyyy

The cells that don't change to a nice long date aren't really dates--they're
text that just look like dates.

In fact, you may find that some of the real dates aren't what you expect.

Is 10-12-2005 really October 12, 2005 or December 10, 2005. With an unambiguous
format, you'll see it right away.



Francis Brown wrote:

I Start with the following dates in the range a8 to b15 in the dd-mm-yyyy
format.

10-12-2005 16-12-2005
03-12-2005 09-12-2005
26-11-2005 02-12-2005
19-11-2005 25-11-2005
12-11-2005 18-11-2005
05-11-2005 11-11-2005
29-10-2005 04-11-2005
22-10-2005 28-10-2005

I then run the following code,

Public Sub copydates()
Worksheets("Sheet2").Range("a8:b15").Value =
Worksheets("Sheet1").Range_("a8:b15").Value
Worksheets("Sheet2").Range("a8:b15").NumberFormat = "dd-mm-yyyy"

End Sub

Which result in the following on the second sheet

12-10-2005 12/16/2005
12-03-2005 12-09-2005
11/26/2005 12-02-2005
11/19/2005 11/25/2005
11-12-2005 11/18/2005
11-05-2005 11-11-2005
10/29/2005 11-04-2005
10/22/2005 10/28/2005

Can someone please explain what excel is doing wrong or more lickley what am
I doing wrong.


--

Dave Peterson