View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.misc
squenson via OfficeKB.com squenson via OfficeKB.com is offline
external usenet poster
 
Posts: 78
Default Conditional Formatting and Entering Dates with out dashes

First question:
Select the range B1:B2345, then click on Format Conditional Formatting,
then select "Cell Content Is", "Equal To", =C1+10. Note that if you had
selected a range B5:B234, then the formula should have been =C5+10. If you
want to always compare to cell C1, then use =$C$1+10.

Second question:
Press ALT+F11, then copy the code below in the sheet where you want to enter
the dates. I guessed that 11207 is 1-Dec-2007 and not 12-Jan-2007. Adapt the
code accordingly by swapping the digits 3 and 1 in the line of code Target.
Value = DateSerial(...

Private Sub Worksheet_Change(ByVal Target As Range)

Dim d As Long
Dim s As String

If Intersect(Target, Range("D2:D999")) Is Nothing Then ' <<< ADAPT THE
RANGE!
Exit Sub
End If

d = Target.Value
If d < 10100 Or d 311299 Then ' Not a date, we do not transform the
content
Exit Sub
End If

s = Format(d, "000000")
Application.EnableEvents = False
Target.Value = DateSerial(Val(Mid(s, 5, 2)), Val(Mid(s, 3, 2)), Val(Mid(s,
1, 2)))
Application.EnableEvents = True

End Sub

Stephane Quenson

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...excel/200708/1