Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default =(TEXT(RIGHT(A1,4),"####")&(TEXT(LEFT(A1,4),"####" )))

Does any one know how to make this affect a selected range? What I'm trying to do is take '20031216' and turn it into '12162003'. It only has to work with 8 digit numbers (dates). I'll admit I don't know what I'm doing, but the following code clears the selected cells. Or, is there a better way to take text dates(20031216) and turn them into something Excel can use as a date

On Error Resume Nex
Dim cel As Rang
Dim myVar As Rang
Set myVar = Selectio

For Each cel In myVa
If Left((Trim(cel)), 4) = "2003" The
cel.Value = Text(Right(cel, 4), "####") & (Text(Left(cel, 4), "####")
End I
Nex

With myVa
.NumberFormat = "########);[Red](########)
.Columns.AutoFi
End Wit
End Su

Any help would be appreciated.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default =(TEXT(RIGHT(A1,4),"####")&(TEXT(LEFT(A1,4),"####" )))

Rik

Try This
=DATE(RIGHT(A26,4),MID(A26,5,2),RIGHT(A26,2))

If you want to write a macro use the DateSerial funtion in
place of Excel'x DATE function

Regards
Peter

-----Original Message-----
Does any one know how to make this affect a selected

range? What I'm trying to do is take '20031216' and turn
it into '12162003'. It only has to work with 8 digit
numbers (dates). I'll admit I don't know what I'm doing,
but the following code clears the selected cells. Or, is
there a better way to take text dates(20031216) and turn
them into something Excel can use as a date?

On Error Resume Next
Dim cel As Range
Dim myVar As Range
Set myVar = Selection

For Each cel In myVar
If Left((Trim(cel)), 4) = "2003" Then
cel.Value = Text(Right(cel, 4), "####") & (Text

(Left(cel, 4), "####"))
End If
Next

With myVar
.NumberFormat = "########);[Red](########)"
.Columns.AutoFit
End With
End Sub

Any help would be appreciated.
.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 422
Default =(TEXT(RIGHT(A1,4),"####")&(TEXT(LEFT(A1,4),"####" )))

=DATE(RIGHT(A26,4),MID(A26,5,2),RIGHT(A26,2))

so/be =DATE(LEFT(A26,4),MID(A26,5,2),RIGHT(A26,2))

I know Peter would agree.


"Peter Atherton" wrote in message
...
Rik

Try This
=DATE(RIGHT(A26,4),MID(A26,5,2),RIGHT(A26,2))

If you want to write a macro use the DateSerial funtion in
place of Excel'x DATE function

Regards
Peter

-----Original Message-----
Does any one know how to make this affect a selected

range? What I'm trying to do is take '20031216' and turn
it into '12162003'. It only has to work with 8 digit
numbers (dates). I'll admit I don't know what I'm doing,
but the following code clears the selected cells. Or, is
there a better way to take text dates(20031216) and turn
them into something Excel can use as a date?

On Error Resume Next
Dim cel As Range
Dim myVar As Range
Set myVar = Selection

For Each cel In myVar
If Left((Trim(cel)), 4) = "2003" Then
cel.Value = Text(Right(cel, 4), "####") & (Text

(Left(cel, 4), "####"))
End If
Next

With myVar
.NumberFormat = "########);[Red](########)"
.Columns.AutoFit
End With
End Sub

Any help would be appreciated.
.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Thank You!

Thanks guys! It took about an hour for me to guess the syntax, but I got it & it works great. I really appreciate it.
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default =(TEXT(RIGHT(A1,4),"####")&(TEXT(LEFT(A1,4),"####" )))

If your data is in a single column, you may want to record a macro when you do
Data|Text to columns. You can specify that's it's a date in ymd format. After
that, you can just format it as a custom date mmddyyyy.



Rik 13 wrote:

Does any one know how to make this affect a selected range? What I'm trying to do is take '20031216' and turn it into '12162003'. It only has to work with 8 digit numbers (dates). I'll admit I don't know what I'm doing, but the following code clears the selected cells. Or, is there a better way to take text dates(20031216) and turn them into something Excel can use as a date?

On Error Resume Next
Dim cel As Range
Dim myVar As Range
Set myVar = Selection

For Each cel In myVar
If Left((Trim(cel)), 4) = "2003" Then
cel.Value = Text(Right(cel, 4), "####") & (Text(Left(cel, 4), "####"))
End If
Next

With myVar
.NumberFormat = "########);[Red](########)"
.Columns.AutoFit
End With
End Sub

Any help would be appreciated.


--

Dave Peterson



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
Text "comparison" operator for "contains" used in an "IF" Function Pawaso Excel Worksheet Functions 4 April 4th 23 11:35 AM
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
how i convert "100" to "hundred"( number to text) in excel-2007 mohanraj Excel Worksheet Functions 1 May 11th 08 09:07 PM
HELP on "left","right","find","len","substitute" functions serene83 Excel Discussion (Misc queries) 5 June 27th 06 02:23 AM
Insert "-" in text "1234567890" to have a output like this"123-456-7890" Alwyn Excel Discussion (Misc queries) 3 October 25th 05 11:36 PM


All times are GMT +1. The time now is 08:37 PM.

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"