#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2
Default Dates in Excel

I am entering past dates in Excel. When I enter a different month & day but
same year in the next row, is there a way to do that without having to enter
the year?
--
Self-taught
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,058
Default Dates in Excel

This example is for column D. If you type a month/day in a cell, it will use
the year from the cell above. So if you click on D2 and type 12/25, it gets
the year from D1 and applies it to D2. This is worksheet event code and
should be put in the worksheet code area:

Private Sub Worksheet_Change(ByVal Target As Range)
Set t = Target
Set d = Range("D:D")
Set d1 = Range("D1")
If Intersect(t, d) Is Nothing Then Exit Sub
If Intersect(t, d1) Is Nothing Then
If IsEmpty(t.Offset(-1, 0)) Then Exit Sub
yr = Year(t.Offset(-1, 0).Value)
Application.EnableEvents = False
v = t.Value
t.Value = DateSerial(yr, Month(v), Day(v))
Application.EnableEvents = True
End If
End Sub
--
Gary''s Student - gsnu200787


"SydneyVada" wrote:

I am entering past dates in Excel. When I enter a different month & day but
same year in the next row, is there a way to do that without having to enter
the year?
--
Self-taught

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2
Default Dates in Excel

Sorry, but that is way above my head. I read up on worksheet event codes,
but I have no idea how or where to put this information.
--
Self-taught


"Gary''s Student" wrote:

This example is for column D. If you type a month/day in a cell, it will use
the year from the cell above. So if you click on D2 and type 12/25, it gets
the year from D1 and applies it to D2. This is worksheet event code and
should be put in the worksheet code area:

Private Sub Worksheet_Change(ByVal Target As Range)
Set t = Target
Set d = Range("D:D")
Set d1 = Range("D1")
If Intersect(t, d) Is Nothing Then Exit Sub
If Intersect(t, d1) Is Nothing Then
If IsEmpty(t.Offset(-1, 0)) Then Exit Sub
yr = Year(t.Offset(-1, 0).Value)
Application.EnableEvents = False
v = t.Value
t.Value = DateSerial(yr, Month(v), Day(v))
Application.EnableEvents = True
End If
End Sub
--
Gary''s Student - gsnu200787


"SydneyVada" wrote:

I am entering past dates in Excel. When I enter a different month & day but
same year in the next row, is there a way to do that without having to enter
the year?
--
Self-taught

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
Excel not recognizing dates as dates lawson Excel Discussion (Misc queries) 1 June 26th 07 04:39 PM
Identifying unique dates in a range of cells containing dates... cdavidson Excel Discussion (Misc queries) 4 October 13th 06 03:30 PM
Identifying unique dates within a range of cells containing dates cdavidson Excel Discussion (Misc queries) 0 October 12th 06 08:19 PM
need to convert list of dates to count no. of dates by week neowok Excel Worksheet Functions 13 January 30th 06 03:54 PM
How do I get the dates on an excel chart to stay as dates instead. Rani Charts and Charting in Excel 1 September 20th 05 05:56 PM


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