Encoding Dates

  • Thread starter Thread starter daniel chen
  • Start date Start date
D

daniel chen

I have dates in column A, and I would like to encode them in column B as
the following;
e.g.
For 12/6/2003 in columnA ColumnB should have 120603 in the same row.
For 8/5/2004 in columnA ColumnB should have 080504 in the same row.
For 8/17/2004 in columnA ColumnB should have 081704 in the same row.
Will someone help me with a formula, as well as VBA code, please.

I tried this one, and got erroneous ans.
Cells(1, 2) = Format(Cells(1, 1), "mmddyy")
 
Hi Daniel!

Try this:

=TEXT(A1,"mmddyy")

Note that the output will be *TEXT*

Biff
 
one way by formula:

=TEXT(A1,"mmddyy")

one way using VBA:

With Cells(1, 2)
.Value = Cells(1, 1).Value
.NumberFormat = "mmddyy"
End With

Note that when VBA enters a value in XL, XL's parser treats it like a
manual entry, so the format you enter it doesn't change how it's
displayed.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top