Ironman
Well-known Member
- Joined
- Jan 31, 2004
- Messages
- 1,069
- Office Version
- 365
- Platform
- Windows
Hi
The below code in a module runs when I click an icon on the toolbar:
I want to assign a Control+\ keyboard shortcut to this instead and I've adapted the below code I've found online and inserted it in the Training Log sheet.
as follows:
There's no error and I can't get it to run.
I'd really appreciate a solution.
Many thanks!
The below code in a module runs when I click an icon on the toolbar:
VBA Code:
Sub FindDate()
Dim myDt As Date
Dim myInput As Variant
Dim CellFound As String
If ActiveSheet.Name <> "Training Log" And ActiveSheet.Name <> "Training 1981-1997" Then
MsgBox "The Locate Entry Date function will only run in Training Log", vbInformation, "Function Invalid in This Sheet"
Exit Sub
Else
End If
On Error GoTo Error1
myInput = InputBox("Enter Date Below: (d/m/yy)", "Locate Training Log Entry Date")
If myInput = "" Then
MsgBox "Search cancelled!", vbInformation, "Locate Training Log Entry Date"
Exit Sub
Else
End If
If IsDate(myInput) Then
myDt = myInput
CellFound = Application.Match(CDbl(myDt), ActiveSheet.Range("A:A"), 0)
ActiveSheet.Range("A" & CellFound).Activate
Exit Sub
Else
End If
Error1:
MsgBox "Sorry, no Training Log entry found for that date", vbInformation, "Search Unsuccessful"
I want to assign a Control+\ keyboard shortcut to this instead and I've adapted the below code I've found online and inserted it in the Training Log sheet.
VBA Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Application.OnKey "^{RETURN}", "MyMacro"
End Sub
as follows:
VBA Code:
Application.OnKey "\^", "FindDate"
I'd really appreciate a solution.
Many thanks!
Last edited: