Eawyne
New Member
- Joined
- Jun 28, 2021
- Messages
- 44
- Office Version
- 2013
- Platform
- Windows
Hi all,
I want to have an inputbox to look for something in a sheet, and when I entered a value in the box, it will add the date to the adjacent cell after getting the focus on it. No need for any action on the cell, just looking for => Date.
I managed to find two codes that do parts of that request, but I'm stuck now, unable to merge them together to get the final result.
This one locates and moves to a cell when finding a value :
This one does apply the Date to the cell containing the found value :
I tried to find exactly what allows to focus, but I just couldn't. Either articles are related to a specific question and thus hard to decypher, or it's too vague because I lack basics on coding...
What I'm looking for are values like this : R0125 ; I'd like to be able to "wildcard" the search, but again, I've been unable to find a specific item to help me out here.
Thanks for any help given !
I want to have an inputbox to look for something in a sheet, and when I entered a value in the box, it will add the date to the adjacent cell after getting the focus on it. No need for any action on the cell, just looking for => Date.
I managed to find two codes that do parts of that request, but I'm stuck now, unable to merge them together to get the final result.
This one locates and moves to a cell when finding a value :
VBA Code:
Sub Find_First()
Dim FindString As String
Dim Rng As Range
FindString = InputBox("Enter a Search value")
If Trim(FindString) <> "" Then
With Sheets("Sheet1").Range("A:A")
Set Rng = .Find(What:=FindString, _
After:=.Cells(.Cells.Count), _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
If Not Rng Is Nothing Then
Application.Goto Rng, True
Else
MsgBox "Nothing found"
End If
End With
End If
End Sub
This one does apply the Date to the cell containing the found value :
VBA Code:
Sub Test()
Boite = Application.InputBox("Indiquez la boite à trouver :", "Boite")
Set found = Range("A:A").Find(What:=Boite, LookIn:=xlValues, LookAt:=xlWhole)
If found Is Nothing Then
MsgBox "Cette boite n'existe pas", vbExclamation
Else
found.Offset(0, 1).Value = Date
End If
End Sub
I tried to find exactly what allows to focus, but I just couldn't. Either articles are related to a specific question and thus hard to decypher, or it's too vague because I lack basics on coding...
What I'm looking for are values like this : R0125 ; I'd like to be able to "wildcard" the search, but again, I've been unable to find a specific item to help me out here.
Thanks for any help given !