Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
M H M H is offline
external usenet poster
 
Posts: 28
Default Conditional Date Formatting

Can I use conditional formatting to change the entry (e.g. in column F,
starting with F6) from "20050721" to a date format like 07/21/2005 with
the formula below?

=DATE(LEFT(F6,4),MID(F6,5,2),RIGHT(F6,2))

Please advice.

*** Sent via Developersdex http://www.developersdex.com ***
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,298
Default Conditional Date Formatting

No. Conditional formatting just changes the way that a cell's value is shown.
It can't actually change the value.
You'd have to write some code to change the cell's value since the YYYMMDD
entry in a cell isn't recognised as a date (at least not in Excel XP)


"M H" wrote:

Can I use conditional formatting to change the entry (e.g. in column F,
starting with F6) from "20050721" to a date format like 07/21/2005 with
the formula below?

=DATE(LEFT(F6,4),MID(F6,5,2),RIGHT(F6,2))

Please advice.

*** Sent via Developersdex http://www.developersdex.com ***

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,120
Default Conditional Date Formatting

Here is a code solution

Private Sub Worksheet_Change(ByVal Target As Range)
Dim mDate

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range("H1:H10")) Is Nothing Then
With Target
mDate = DateSerial(Left(.Value, 4), Mid(.Value, 5, 2),
Right(.Value, 2))
If IsDate(mDate) Then
.Value = mDate
End If
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.



--
HTH

Bob Phillips

"M H" wrote in message
...
Can I use conditional formatting to change the entry (e.g. in column F,
starting with F6) from "20050721" to a date format like 07/21/2005 with
the formula below?

=DATE(LEFT(F6,4),MID(F6,5,2),RIGHT(F6,2))

Please advice.

*** Sent via Developersdex http://www.developersdex.com ***



  #4   Report Post  
Posted to microsoft.public.excel.programming
M H M H is offline
external usenet poster
 
Posts: 28
Default Conditional Date Formatting

Thanks, Bob. It's a magic!



*** Sent via Developersdex http://www.developersdex.com ***
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,120
Default Conditional Date Formatting

No, it's event code <vbg

Bob

"M H" wrote in message
...
Thanks, Bob. It's a magic!



*** Sent via Developersdex http://www.developersdex.com ***





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
conditional formatting for cell date to equal today's date Sistereinstein Excel Worksheet Functions 2 September 10th 12 07:53 PM
Date Conditional Formatting Ray Excel Worksheet Functions 4 December 19th 09 08:45 PM
date conditional formatting lolan7 Excel Discussion (Misc queries) 0 December 2nd 09 04:14 PM
Conditional Formatting - due date Rod from Corrections Excel Worksheet Functions 4 February 5th 07 09:39 PM
conditional formatting date Derek Excel Worksheet Functions 3 October 11th 06 06:22 PM


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