Ironman
Well-known Member
- Joined
- Jan 31, 2004
- Messages
- 1,069
- Office Version
- 365
- Platform
- Windows
Hi
The below code searches Sheet 1 ('Training Log') for a date in Column 1.
I'm looking for a small amendment to this so the code will also search the same column in Sheet 20 ('Training 1981-1997').
The code is also contained in Sheet 1 and Sheet 20 under
Can the amended code search Sheet 20 in Sheet 1 and vice versa, or can it only search the sheet that the code is in? If it won't do this, I presume it would need to be inserted in This Workbook?
Many thanks!
The below code searches Sheet 1 ('Training Log') for a date in Column 1.
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"
End Sub
I'm looking for a small amendment to this so the code will also search the same column in Sheet 20 ('Training 1981-1997').
The code is also contained in Sheet 1 and Sheet 20 under
VBA Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Many thanks!
Last edited: