LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #26   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Copy Range to new Range and keep DATE format??

Cells with Dates/times and currencies are special in excel.

..value2 returns the underlying value (the serial number of the date) of the
cell.

VBA's help describes it in more detail.

" wrote:

Thanks for the help Dave.

What is the difference between .Value and .Value2 as an object?

Which Excel parsing routine are you talking about?
You are right about the dates, thats exactly what is happening.
I removed the Format and use Cdate instead anywhere a new date value
is added.
I think I will keep the copy line as well, it's working and I am tired
of messing with this. :)

Cheers

On Jul 13, 11:24 pm, Dave Peterson wrote:
Yep.

If you use format(), then it's like typing the value into the cell.

And if your windows short date setting is mdy and you type: 1/2/2003, you'll
get Jan 2, 2003.

Even if you expected February, 1, 2003.

I think it's better to just assign the value (or .value2) and use the number
format to make it look pretty. Take excel's parsing routine completely out of
the process.





" wrote:

Value2 does work!!! Finally.


I think you figured this out so dont make me wait any longer. :)


As for the ambigous format, yes it would change on the range M10, but
M3 range would be messed up the same way,


If the text of what you see in the cells doesn't change after you change the
format, then your values aren't really dates--it's just text that looks (to you)
like dates.


I thought of that, maybe the FORMAT in the line :
hisWorkbook.Sheets("Settings").Range(TempWeekRange +
CStr(NewWeekFlag + Sales)).Value = Format(StartWeek, "dd/mmm/yyyy")


is to blame?
I will switch it to CDATE instead and check it out.


On Jul 13, 7:52 pm, Dave Peterson wrote:
ps. I'm curious what happens when you change the numberformat to that
unambiguous date format, but I bet your code will work if you use:


.value2 = .value2


Dave Peterson wrote:


Try formatting your values using an unambiguous date format:


MMMM DD, YYYY


And then see what happens.


If the text of what you see in the cells doesn't change after you change the
format, then your values aren't really dates--it's just text that looks (to you)
like dates.


" wrote:


You code produces the same result even on an empty workbook.
The month and day are reversed.


The copy method does work, I've been testing it alot to make sure.
I dont understand why .value=.value does not work...
I wish someone would be able to explain this to me for future
reference.


On Jul 13, 4:02 pm, Dave Peterson wrote:
Does my first suggestion work in a test workbook?


Are you sure this worked?


" wrote:


Well I guess I will have to use


ThisWorkbook.Sheets("Settings").Range(TempWeekRang e + "10" + ":" +
TempWeekRange + "15").Copy _
Destination:=ThisWorkbook.Sheets("Settings").Range (TempWeekRange +
"10" + ":" + TempWeekRange + "15")
At least this one works... :)


--


Dave Peterson


--


Dave Peterson


--


Dave Peterson


--

Dave Peterson


--

Dave Peterson
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Find Last cell in Range when range is date format default105 Excel Discussion (Misc queries) 5 July 7th 09 03:11 PM
Stubborn date format and range copy Mathieu Excel Programming 2 August 21st 07 04:16 PM
copy date based on date -refer to date range mindpeace[_4_] Excel Programming 1 June 3rd 06 01:30 PM
How to copy a range with same format !! tttoan Excel Programming 1 May 26th 05 02:14 PM
Find date and copy range based on that date avzundert Excel Programming 2 November 25th 04 10:31 AM


All times are GMT +1. The time now is 10:01 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"