Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default From MMDDYY to YYMMDD

Hey Guys,

I have a column of dates in a text format as MMDDYY. I need to turn it into
YYMMDD. I have so many rows that I dont see myself manually reformating each
row of data to the YYMMDD format.

How can I code this to do it automatically for the whole column?

Thanks for your help. It is always appreciated.

Alec
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,163
Default From MMDDYY to YYMMDD

Select the entire column by clicking on the column header (where it has the
column labels A B C etc.) and then use the Format menu to change the format
for that entire column.
--
- K Dales


"Alec" wrote:

Hey Guys,

I have a column of dates in a text format as MMDDYY. I need to turn it into
YYMMDD. I have so many rows that I dont see myself manually reformating each
row of data to the YYMMDD format.

How can I code this to do it automatically for the whole column?

Thanks for your help. It is always appreciated.

Alec

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default From MMDDYY to YYMMDD

To supplement K Dales fine advice:

In VBA that would be

Sub FormatColumn()
ActiveCell.Entirecolumn.NumberFormat = "YYMMDD"
End Sub

this assumes your values are stored as dates and formatting determines how
they appear.

However you use of the term "text format" is troubling. If they are really
text entries

Sub AlterColumn()
Dim cell as Range
Dim sStr as String, sStr1 as String
for each cell in selection
if len(cell.Text) = 8 then
sStr = cell.Text
sStr1 = Right(sStr,2) & Left(sStr,2) & Mid(sStr,2,2)
cell.Value = "'" & sStr1
end if
Next
End Sub

Select the cells to "format" and run the macro.



--
Regards,
Tom Ogilvy

"K Dales" wrote in message
...
Select the entire column by clicking on the column header (where it has

the
column labels A B C etc.) and then use the Format menu to change the

format
for that entire column.
--
- K Dales


"Alec" wrote:

Hey Guys,

I have a column of dates in a text format as MMDDYY. I need to turn it

into
YYMMDD. I have so many rows that I dont see myself manually reformating

each
row of data to the YYMMDD format.

How can I code this to do it automatically for the whole column?

Thanks for your help. It is always appreciated.

Alec



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default From MMDDYY to YYMMDD

if len(cell.Text) = 8 then

should be

if len(cell.Text) = 6 then

--
Regards,
Tom Ogilvy


"Tom Ogilvy" wrote in message
...
To supplement K Dales fine advice:

In VBA that would be

Sub FormatColumn()
ActiveCell.Entirecolumn.NumberFormat = "YYMMDD"
End Sub

this assumes your values are stored as dates and formatting determines how
they appear.

However you use of the term "text format" is troubling. If they are

really
text entries

Sub AlterColumn()
Dim cell as Range
Dim sStr as String, sStr1 as String
for each cell in selection
if len(cell.Text) = 8 then
sStr = cell.Text
sStr1 = Right(sStr,2) & Left(sStr,2) & Mid(sStr,2,2)
cell.Value = "'" & sStr1
end if
Next
End Sub

Select the cells to "format" and run the macro.



--
Regards,
Tom Ogilvy

"K Dales" wrote in message
...
Select the entire column by clicking on the column header (where it has

the
column labels A B C etc.) and then use the Format menu to change the

format
for that entire column.
--
- K Dales


"Alec" wrote:

Hey Guys,

I have a column of dates in a text format as MMDDYY. I need to turn it

into
YYMMDD. I have so many rows that I dont see myself manually

reformating
each
row of data to the YYMMDD format.

How can I code this to do it automatically for the whole column?

Thanks for your help. It is always appreciated.

Alec





  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default From MMDDYY to YYMMDD

This does not work. The format option is worthless in that case. This is a
text format and not even DateValue function changes my data.

Do you guys have a VBA coding for this?

Thanks.

"K Dales" wrote:

Select the entire column by clicking on the column header (where it has the
column labels A B C etc.) and then use the Format menu to change the format
for that entire column.
--
- K Dales


"Alec" wrote:

Hey Guys,

I have a column of dates in a text format as MMDDYY. I need to turn it into
YYMMDD. I have so many rows that I dont see myself manually reformating each
row of data to the YYMMDD format.

How can I code this to do it automatically for the whole column?

Thanks for your help. It is always appreciated.

Alec



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,119
Default From MMDDYY to YYMMDD

So just to be clear you have a bunch of text values not a bunch of date
values. If that is the case then

Public Function ChangeTextDate(ByVal rngDate As Range) As String
Dim strDay As String
Dim strMonth As String
Dim strYear As String

strDay = Mid(rngDate.Value, 3, 2)
strMonth = Left(rngDate.Value, 2)
strYear = Mid(rngDate.Value, 5, 2)

ChangeTextDate = strYear & strMonth & strDay
End Function

Sub test()
Dim rngToChange As Range
Dim wks As Worksheet
Dim rngCurrent As Range

Set wks = ActiveSheet
Set rngToChange = Intersect(wks.UsedRange, wks.Columns("B"))

For Each rngCurrent In rngToChange
If Len(rngCurrent.Value) = 6 Then _
rngCurrent.Value = ChangeTextDate(rngCurrent)
Next rngCurrent
End Sub

--
HTH...

Jim Thomlinson


"Alec" wrote:

This does not work. The format option is worthless in that case. This is a
text format and not even DateValue function changes my data.

Do you guys have a VBA coding for this?

Thanks.

"K Dales" wrote:

Select the entire column by clicking on the column header (where it has the
column labels A B C etc.) and then use the Format menu to change the format
for that entire column.
--
- K Dales


"Alec" wrote:

Hey Guys,

I have a column of dates in a text format as MMDDYY. I need to turn it into
YYMMDD. I have so many rows that I dont see myself manually reformating each
row of data to the YYMMDD format.

How can I code this to do it automatically for the whole column?

Thanks for your help. It is always appreciated.

Alec

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 863
Default From MMDDYY to YYMMDD

The problem is, you said you had "dates". A date in Excel is the number of
elapsed days since Dec 31, 1899. Today, Sep 28 2005, is the number 38623, not
the number 92805. To convert your numbers to true dates, you can use Data/Text
to Columns. Select the column of "dates", and at the 3rd dialog box specify
that the column is a date, format mdy.

Or you can use a "helper column" with a formula such as

=DATE(MOD(A1,100)+2000,INT(A1/10000),MOD(INT(A1/100),100))


On Wed, 28 Sep 2005 09:46:03 -0700, "Alec"
wrote:

This does not work. The format option is worthless in that case. This is a
text format and not even DateValue function changes my data.

Do you guys have a VBA coding for this?

Thanks.

"K Dales" wrote:

Select the entire column by clicking on the column header (where it has the
column labels A B C etc.) and then use the Format menu to change the format
for that entire column.
--
- K Dales


"Alec" wrote:

Hey Guys,

I have a column of dates in a text format as MMDDYY. I need to turn it

into
YYMMDD. I have so many rows that I dont see myself manually reformating

each
row of data to the YYMMDD format.

How can I code this to do it automatically for the whole column?

Thanks for your help. It is always appreciated.

Alec

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default From MMDDYY to YYMMDD

Thanks. You guys are great.

"Jim Thomlinson" wrote:

So just to be clear you have a bunch of text values not a bunch of date
values. If that is the case then

Public Function ChangeTextDate(ByVal rngDate As Range) As String
Dim strDay As String
Dim strMonth As String
Dim strYear As String

strDay = Mid(rngDate.Value, 3, 2)
strMonth = Left(rngDate.Value, 2)
strYear = Mid(rngDate.Value, 5, 2)

ChangeTextDate = strYear & strMonth & strDay
End Function

Sub test()
Dim rngToChange As Range
Dim wks As Worksheet
Dim rngCurrent As Range

Set wks = ActiveSheet
Set rngToChange = Intersect(wks.UsedRange, wks.Columns("B"))

For Each rngCurrent In rngToChange
If Len(rngCurrent.Value) = 6 Then _
rngCurrent.Value = ChangeTextDate(rngCurrent)
Next rngCurrent
End Sub

--
HTH...

Jim Thomlinson


"Alec" wrote:

This does not work. The format option is worthless in that case. This is a
text format and not even DateValue function changes my data.

Do you guys have a VBA coding for this?

Thanks.

"K Dales" wrote:

Select the entire column by clicking on the column header (where it has the
column labels A B C etc.) and then use the Format menu to change the format
for that entire column.
--
- K Dales


"Alec" wrote:

Hey Guys,

I have a column of dates in a text format as MMDDYY. I need to turn it into
YYMMDD. I have so many rows that I dont see myself manually reformating each
row of data to the YYMMDD format.

How can I code this to do it automatically for the whole column?

Thanks for your help. It is always appreciated.

Alec

  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default From MMDDYY to YYMMDD

Alec

This works for me.

Select the column then DataText to ColumnsNextNextColumn Data
FormatDateMDYFinish

Now Custom Format to YYMMDD


Gord Dibben Excel MVP

On Wed, 28 Sep 2005 09:21:06 -0700, "Alec"
wrote:

Hey Guys,

I have a column of dates in a text format as MMDDYY. I need to turn it into
YYMMDD. I have so many rows that I dont see myself manually reformating each
row of data to the YYMMDD format.

How can I code this to do it automatically for the whole column?

Thanks for your help. It is always appreciated.

Alec


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
how can I change MMDDYY to YYYYMMDD? mhayes Excel Discussion (Misc queries) 2 April 21st 10 11:11 PM
Convert mm/dd/yyyy to mmddyy Annette Excel Discussion (Misc queries) 9 September 22nd 09 09:39 PM
How do you change a date that is in the yyyymmdd format to mmddyy Norton Excel Discussion (Misc queries) 2 March 8th 06 03:15 PM
Convert 010105 mmddyy text to 01/01/06 supersonicf111 Excel Discussion (Misc queries) 10 January 2nd 06 01:56 AM
change datestamp from yyyy-mm-dd to yymmdd jst_se Excel Programming 3 July 22nd 04 06:30 PM


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