PC Review


Reply
Thread Tools Rate Thread

Date Change macro

 
 
=?Utf-8?B?RXNjaHJvZXRlcg==?=
Guest
Posts: n/a
 
      15th Feb 2007
In Microsoft Money and Quicken, you have the ability to change the date up or
down by using the "+" and "-" keys. Does anyone know of a way to do that in
Excel? For instance, suppose you had a column of dates. I'm looking for a
way to arrow down this column and adjust each date accordingly by hitting the
plus or minus keys instead of manually retyping each date.
 
Reply With Quote
 
 
 
 
=?Utf-8?B?ZGtpbm4=?=
Guest
Posts: n/a
 
      15th Feb 2007
here is something that might get you started
Put this in ThisWorkbook

Private Sub Workbook_Open()
Application.OnKey "{+}", "AddDay"
Application.OnKey "{-}", "SubtractDay"
End Sub

and put this into a standard module

Sub AddDay()
If IsDate(ActiveCell.Value) Then ActiveCell.Value = ActiveCell.Value + 1

End Sub

Sub SubtractDay()
If IsDate(ActiveCell.Value) Then ActiveCell.Value = ActiveCell.Value - 1
End Sub


It will trap the + and - from the main keyboard (I haven't found the right
key for the numeric keypad yet)

If the active cell contains a date it will add or subtract one day from the
orginal date

it's a starting point

David

"Eschroeter" wrote:

> In Microsoft Money and Quicken, you have the ability to change the date up or
> down by using the "+" and "-" keys. Does anyone know of a way to do that in
> Excel? For instance, suppose you had a column of dates. I'm looking for a
> way to arrow down this column and adjust each date accordingly by hitting the
> plus or minus keys instead of manually retyping each date.

 
Reply With Quote
 
Tom Ogilvy
Guest
Posts: n/a
 
      15th Feb 2007
Look at the OnKey command - see Excel VBA help. Tie the keys you want to
a macro that increases or decreases the value of the activecell.

--
Regards,
Tom Ogilvy



"Eschroeter" <(E-Mail Removed)> wrote in message
news:0CF66589-F2A5-4A33-8E98-(E-Mail Removed)...
> In Microsoft Money and Quicken, you have the ability to change the date up
> or
> down by using the "+" and "-" keys. Does anyone know of a way to do that
> in
> Excel? For instance, suppose you had a column of dates. I'm looking for
> a
> way to arrow down this column and adjust each date accordingly by hitting
> the
> plus or minus keys instead of manually retyping each date.



 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      15th Feb 2007
How about an alternative?

You could use the right click to decrement and double click to increment.

If you want to try, rightclick on the worksheet tab that should have this
behavior. Select view code and paste this into the code window:

Option Explicit
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, _
Cancel As Boolean)
If Target.Cells.Count > 1 Then Exit Sub
If Intersect(Target, Me.Range("A:A")) Is Nothing Then Exit Sub

Cancel = True 'stop editing in cell
If IsDate(Target.Value) Then
Target.Value = Target.Value + 1
End If
End Sub

Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, _
Cancel As Boolean)
If Target.Cells.Count > 1 Then Exit Sub
If Intersect(Target, Me.Range("A:A")) Is Nothing Then Exit Sub

Cancel = True 'stop pop up from showing
If IsDate(Target.Value) Then
Target.Value = Target.Value - 1
End If
End Sub

I used column A in my code--change the range to what you want.

Eschroeter wrote:
>
> In Microsoft Money and Quicken, you have the ability to change the date up or
> down by using the "+" and "-" keys. Does anyone know of a way to do that in
> Excel? For instance, suppose you had a column of dates. I'm looking for a
> way to arrow down this column and adjust each date accordingly by hitting the
> plus or minus keys instead of manually retyping each date.


--

Dave Peterson
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Date Change Macro =?Utf-8?B?RXNjaHJvZXRlcg==?= Microsoft Excel Worksheet Functions 2 15th Feb 2007 02:15 PM
Date change button/macro =?Utf-8?B?S2FtcmFu?= Microsoft Excel Programming 2 2nd Oct 2006 03:45 PM
macro to change date ranges =?Utf-8?B?RGFycmVu?= Microsoft Excel Programming 2 2nd Feb 2006 03:28 PM
macro to change date ranges =?Utf-8?B?RGFycmVu?= Microsoft Excel Misc 2 5th Jan 2006 03:49 PM
Macro to change tab name to date from a cell ref =?Utf-8?B?Y3dpbHNvbg==?= Microsoft Excel Programming 4 8th Mar 2004 09:31 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:13 AM.