Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default assign the formatted cell value (date) to another cell?

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default assign the formatted cell value (date) to another cell?

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" wrote in message
...
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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default assign the formatted cell value (date) to another cell?

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:MM:DD 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
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default assign the formatted cell value (date) to another cell?

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" wrote in message
...
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:MM:DD 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
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
cell formatted as date won't change NEHicks Excel Discussion (Misc queries) 5 March 14th 21 11:52 AM
Extracting date from Date and Time formatted cell Aviral Sharma Excel Discussion (Misc queries) 2 March 6th 09 05:04 AM
comparing abr. Date Text cell to a date formatted cell David B Excel Programming 0 April 24th 08 05:46 PM
how do i add 1 year to a date formatted cell? rogerm Excel Worksheet Functions 5 September 4th 05 06:46 AM
need to split month out from date formatted cell John R.[_3_] Excel Programming 4 November 22nd 03 02:54 AM


All times are GMT +1. The time now is 01:57 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"