PC Review


Reply
Thread Tools Rate Thread

assign the formatted cell value (date) to another cell?

 
 
Lars Uffmann
Guest
Posts: n/a
 
      18th Aug 2008
Hi everyone, simple question and I'm hoping there's a simple answer:

I have a date column A (double value), and I need it formatted in column
B for output to a text file. I'd like to do the equivalent of

Range("B:B").Formula = "Format(RC1, ""YYYY-DD-MM\Thh:mm:ss"")"

Sadly, Excel will not have the Format function in a cell. It's kinda
ridiculous that I fail to do what I want, because setting the columns
Range("A:A").NumberFormat = "YYYY-DD-MM\Thh:mm:ss"
does exactly what I want, except that it does not store the formatted
string in the cells value.

Is there any way to assign this formatted value as the .value to another
cell? Or does someone know a workaround?

Thanks in advance!

Lars
 
Reply With Quote
 
 
 
 
Peter T
Guest
Posts: n/a
 
      18th Aug 2008
The "TEXT" worksheet function is pretty much the equivalent of VB's Format
function

=TEXT(A1,"YYYY-DD-MM\Thh:mm:ss")

or with code
range("a1") = Now
Range("b2").Formula = "=TEXT(A1,""YYYY-DD-MM\Thh:mm:ss"")"

Regards,
Peter T

"Lars Uffmann" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi everyone, simple question and I'm hoping there's a simple answer:
>
> I have a date column A (double value), and I need it formatted in column B
> for output to a text file. I'd like to do the equivalent of
>
> Range("B:B").Formula = "Format(RC1, ""YYYY-DD-MM\Thh:mm:ss"")"
>
> Sadly, Excel will not have the Format function in a cell. It's kinda
> ridiculous that I fail to do what I want, because setting the columns
> Range("A:A").NumberFormat = "YYYY-DD-MM\Thh:mm:ss"
> does exactly what I want, except that it does not store the formatted
> string in the cells value.
>
> Is there any way to assign this formatted value as the .value to another
> cell? Or does someone know a workaround?
>
> Thanks in advance!
>
> Lars



 
Reply With Quote
 
Lars Uffmann
Guest
Posts: n/a
 
      18th Aug 2008
Peter,

Peter T wrote:
> The "TEXT" worksheet function is pretty much the equivalent of VB's Format
> function


Thank you very much, that is exactly what I wanted to know Though I
do kind of wonder why I have to know 2 different function names for
doing the same thing in VBA or cell formulas...

The only issue here is - while assigning "YYYY:MMD hh:mm:ss" to the
NumberFormat works perfecly, the format string passed to the text
function in the cells formula does not convert the format string to the
computer's region settings, and thus if you have german regional
settings (and the irony is - I made a point of setting my system up with
an english XP!) - it will only work if you use "JJJJ-MM-DD" etc. for the
format string. Go figure...

Thanks a lot, case closed I guess

Best Regards,

Lars
 
Reply With Quote
 
Rick Rothstein \(MVP - VB\)
Guest
Posts: n/a
 
      18th Aug 2008
The two functions are not the same... they have some functional overlaps
between them (the usage you asked about being one of them), but there are
many differences between them as well. The two functions exist in different
worlds and, as such, have functionalities built in which cater to the worlds
they exist in.

Rick


"Lars Uffmann" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Peter,
>
> Peter T wrote:
>> The "TEXT" worksheet function is pretty much the equivalent of VB's
>> Format function

>
> Thank you very much, that is exactly what I wanted to know Though I do
> kind of wonder why I have to know 2 different function names for doing the
> same thing in VBA or cell formulas...
>
> The only issue here is - while assigning "YYYY:MMD hh:mm:ss" to the
> NumberFormat works perfecly, the format string passed to the text function
> in the cells formula does not convert the format string to the computer's
> region settings, and thus if you have german regional settings (and the
> irony is - I made a point of setting my system up with an english XP!) -
> it will only work if you use "JJJJ-MM-DD" etc. for the format string. Go
> figure...
>
> Thanks a lot, case closed I guess
>
> Best Regards,
>
> Lars


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
cell formatted as date won't change NEHicks Microsoft Excel Misc 3 21st Jul 2009 06:31 PM
assign formatted cell value to another cell Lars Uffmann Microsoft Excel Discussion 4 18th Aug 2008 03:19 PM
comparing abr. Date Text cell to a date formatted cell David B Microsoft Excel Programming 0 24th Apr 2008 05:46 PM
how do i add 1 year to a date formatted cell? =?Utf-8?B?cm9nZXJt?= Microsoft Excel Worksheet Functions 5 4th Sep 2005 06:46 AM
Excel date formatted cell displays date entered as Jan-01-1900 =?Utf-8?B?RGVybW90?= Microsoft Excel Crashes 0 29th Sep 2004 11:35 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:47 PM.