Sandman1985
New Member
- Joined
- Jun 22, 2022
- Messages
- 19
- Office Version
- 365
- Platform
- Windows
Hi All,
Hope you're all well.
Have been playing with some VBA to try and create a search and select function and really struggling. My spreadsheet is basically a massive table and has dates in Row 8.
With my code below, I have got an input box to come up to enable a user to enter in a date and be taken to the column where that date exists - did try this with a fixed input cell too but failed there.
My dates start at G8 and finish at EAI8 so have tried to define my search range in the code. Each time I run it, i get the "Not Found" message box. If I use the regular Find function, it actually works fine.
Sub Search()
Dim Find As String
Dim Rng1 As Range
FindS = InputBox("Enter the date you want to search")
With Sheets("Scheduler View").Range("G8:EAI8")
Set Rng = .Find(What:=FindString, After:=Range("G8"))
If Not Rng Is Nothing Then
Application.Goto Rng, True
Else
MsgBox "Not found"
End If
End With
End Sub
Not sure where I have gone wrong, but any help would be greatly appreciated.
Cheers,
Sandman
Hope you're all well.
Have been playing with some VBA to try and create a search and select function and really struggling. My spreadsheet is basically a massive table and has dates in Row 8.
With my code below, I have got an input box to come up to enable a user to enter in a date and be taken to the column where that date exists - did try this with a fixed input cell too but failed there.
My dates start at G8 and finish at EAI8 so have tried to define my search range in the code. Each time I run it, i get the "Not Found" message box. If I use the regular Find function, it actually works fine.
Sub Search()
Dim Find As String
Dim Rng1 As Range
FindS = InputBox("Enter the date you want to search")
With Sheets("Scheduler View").Range("G8:EAI8")
Set Rng = .Find(What:=FindString, After:=Range("G8"))
If Not Rng Is Nothing Then
Application.Goto Rng, True
Else
MsgBox "Not found"
End If
End With
End Sub
Not sure where I have gone wrong, but any help would be greatly appreciated.
Cheers,
Sandman