AshleyKitsune
New Member
- Joined
- Nov 30, 2021
- Messages
- 12
- Office Version
- 2016
- Platform
- Windows
Hi all, this is my first post here, but I've been a long time learner of vba. This is the first time I've ever tried to do something like this and I haven't been able to make it work, sadly.
I wanted to create a key combination that would add 1 to a cells value if it was a date. I also intend to do a subtraction method. After reviewing online for over an hour, I figured it was time to ask for help.
The key combination desired was Ctrl + shift + the Plus key (on the number pad)
The thing is - I want to be able to use this no matter what spreadsheet I have open, so I put it inside my personal.xlsb workbook's workbook tab.. is this not possible? Or do you think my company's policy settings are preventing me? Or am I just plain doing it wrong?
Thank you, Ashley.
I wanted to create a key combination that would add 1 to a cells value if it was a date. I also intend to do a subtraction method. After reviewing online for over an hour, I figured it was time to ask for help.
The key combination desired was Ctrl + shift + the Plus key (on the number pad)
The thing is - I want to be able to use this no matter what spreadsheet I have open, so I put it inside my personal.xlsb workbook's workbook tab.. is this not possible? Or do you think my company's policy settings are preventing me? Or am I just plain doing it wrong?
Thank you, Ashley.
VBA Code:
Option Explicit
Private Sub Workbook_Activate()
Application.OnKey "+^{+}", "AddDayToDate()"
End Sub
Private Sub Workbook_Deactivate()
Application.OnKey "+^{+}"
End Sub
Sub AddDayToDate()
'
' AddDayToDate Macro
'
Dim myDate As Date
If IsDate(ActiveCell) Then
myDate = ActiveCell.Value + 1
ActiveCell.Value = myDate
Else: MsgBox "Cell is not a date value."
End If
End Sub