R
RPTZ
I was shown a code and I think it was misunderstood.
Not sure how to slighty modify the part of the code to do a search.
It was suppose to search for the value in Sheet1 A1 ( fixed location)
in Sheet 2 "anywhere"
So if the macro is running and it reaches the point to find the value
of Sheet 1 A1, then Select Sheet 2, find the same value anywhere in
Sheet 2, and then select that cell.
From there I have the rest covered after the End If
The code I was shown looks like this:
-----------------------------------------------
Sub Find_First()
Dim FindString As String
Dim Rng As Range
FindString = InputBox("Enter a Search value")
If Trim(FindString) <> "" Then
Set Rng = Range("A:A").find(What:=FindString, _
After:=Range("A" & Rows.Count), _
LookIn:=xlFormulas, _
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 If
End Sub ( or continue with the rest of the macro)
But the misunderstanding was where it shows;
FindString = InputBox("Enter a Search value")
This means it has to be typed in. There is no need to type in the
value, it is always in the same location.
It changes value, is when the macro was activated before anyway.
How can I then make that piece of macro code, go to Sheet 2 and locate
the same value as in Sheet 1 A1 without requireinf to type in a value
?
Much appreciated
Not sure how to slighty modify the part of the code to do a search.
It was suppose to search for the value in Sheet1 A1 ( fixed location)
in Sheet 2 "anywhere"
So if the macro is running and it reaches the point to find the value
of Sheet 1 A1, then Select Sheet 2, find the same value anywhere in
Sheet 2, and then select that cell.
From there I have the rest covered after the End If
The code I was shown looks like this:
-----------------------------------------------
Sub Find_First()
Dim FindString As String
Dim Rng As Range
FindString = InputBox("Enter a Search value")
If Trim(FindString) <> "" Then
Set Rng = Range("A:A").find(What:=FindString, _
After:=Range("A" & Rows.Count), _
LookIn:=xlFormulas, _
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 If
End Sub ( or continue with the rest of the macro)
But the misunderstanding was where it shows;
FindString = InputBox("Enter a Search value")
This means it has to be typed in. There is no need to type in the
value, it is always in the same location.
It changes value, is when the macro was activated before anyway.
How can I then make that piece of macro code, go to Sheet 2 and locate
the same value as in Sheet 1 A1 without requireinf to type in a value
?
Much appreciated