How to enter excel dates for last year?

J

JCarlosJr

Hi gang,

Its tax time and I'm trying to enter my expenses ito EXCEL for last year
(don't even remind me I should do this as the year progresses).

Anyway, for speed of entry I would like to enter just mm/dd. Excel will
complete the year for me as 2010.

I could change the system date, but this has bad reprocussions, especaill
when multi-tasking.

I could create a column which subtracts 365 from my entry column and then
paste values from my "dummy" column into my entry column.

BUT, does anyone have a better suggestion to force dates entered on a
specific book, sheet, or even colum to s different default year than the
system date year?
 
G

Gord Dibben

Excel assumes current year when entering just mm/dd

Think about it.............how would Excel know which year you wanted if
none specified?

Without using the adjacent column trick you must add the year in your entry

mm/dd/yy


Gord Dibben MS Excel MVP
 
B

Billns

Hi gang,

Its tax time and I'm trying to enter my expenses ito EXCEL for last year
(don't even remind me I should do this as the year progresses).

Anyway, for speed of entry I would like to enter just mm/dd. Excel will
complete the year for me as 2010.

I could change the system date, but this has bad reprocussions, especaill
when multi-tasking.

I could create a column which subtracts 365 from my entry column and then
paste values from my "dummy" column into my entry column.

BUT, does anyone have a better suggestion to force dates entered on a
specific book, sheet, or even colum to s different default year than the
system date year?

If the dates are all last year, why do you even need to display the year
or care which one it really is? Format the column as mm/dd.

Bill
 
D

Don Guillett

Agree that you don't care about the year but to do as you ask for numbers in
col A
right click sheet tab>view code>insert this>format your column as desired.

Private Sub Worksheet_Change(ByVal Target As Range)
If Not IsNumeric(Target) Or Target.Column <> 1 Then Exit Sub
Target.Value = DateSerial(2009, Month(Target), Day(Target))
End Sub
 
T

tompl

I could not get that to work but this did:

Private Sub Worksheet_Change(ByVal Target As Range)
If Not IsDate(Target) Or Target.Column <> 1 Then Exit Sub
Target.Value = DateSerial(2009, Month(Target), Day(Target))
End Sub

Tom
 
J

Joe User

Billns said:
If the dates are all last year, why do you even need to display the
year or care which one it really is? Format the column as mm/dd.

Or if JCarlos would like the date to __appear__ as 2009, enter dates in the
form mm/dd, but use the Custom format mm/dd/"09" or something like that.


----- original message -----
 
J

Joe User

tompl said:
I could not get that to work but this did:

Private Sub Worksheet_Change(ByVal Target As Range)
If Not IsDate(Target) Or Target.Column <> 1 Then Exit Sub
Target.Value = DateSerial(2009, Month(Target), Day(Target))
End Sub

Well, it might __appear__ to work. But it results in 226 calls for each
change to a date, at least in Excel 2003 / VBA 6.5.1024.

I think it is (usually) prudent to disable events in event macros.
Something like:

Private Sub Worksheet_Change(ByVal Target As Range)
If Not IsDate(Target) Or Target.Column <> 1 Then Exit Sub
Application.EnableEvents = False
Target.Value = DateSerial(2009, Month(Target), Day(Target))
Application.EnableEvents = True
End Sub

I usually use On Error to ensure that EnableEvents=True is executed even if
there is an error. But this macro seems straight-forward enough.


----- original message -----
 
D

Don Guillett

I re-tested using the ISDATE in xl2003 all updates without a glitch using
4/1. I also do the disable if testing shows a need.........On error was also
not needed. I have been doing this for more than a week...... However, I DO
sometimes make mistakes.....
 
×

מיכ×ל (מיקי) ×בידן

This might solve the typing and "appearance" but produce woeful results, if
he needs to run any calculations on those "dates" - and he didn't emphasize
that he do not...
Micky
 
J

Joe User

מיכ×ל (מיקי) ×בידן said:
This might solve the typing and "appearance" but produce woeful results,
if he needs to run any calculations on those "dates"

My comments make the same assumption that Billns makes, namely: "if the
dates are __all__ last year". Since neither 2009 nor 2010 is a leap year, I
believe, as Billns's does, that date calculations will have the same result
regardless of which year is actually used.

If your point is to challenge Billns's assumption, that's fine. But he did
say "if". It is up to JCarlos (and others) to read the comments carefully.

That said, I would prefer the Workbook_Change solution suggested by Don and
Tom. It is the more general solution for __all__ years.


----- original message -----
 
×

מיכ×ל (מיקי) ×בידן

I have no intention to challenge Billns's, or any others assumption all I had
in mine is the lack of possibility to run calculations with your solution.
I also prefer the ALL YEARS Workbook_Change solution suggested by [Toms
wasn't there when I first responsed].
I can assure you that I face a lot of questions where the OP writes 2009 and
after getting solutions) that are directed to meet only the year 2009 he
returns to ask "...and what if I want it to be applied to another year".
This is what I, usually, try [maybe not always successfully] to avoid] and
therefor try to present as general solution that I can think of except for
cases where the OP makes it very clear that he is looking for a specific
solution.
Hope I made myself clear.
Micky
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top