Creating a search box

  • Thread starter Thread starter cornishbloke
  • Start date Start date
C

cornishbloke

I am trying to create a cell in sheet1, into which I can enter a
person's name that appears in column B of sheet2. After entering the
name I want to be able to press a button which then takes you to the
name entered in Sheet2.

So far the closest i've got is to record the following macro: -

Range("C5").Select
Selection.Copy
Sheets("Sheet2").Select
Cells.Find(What:="testname", After:=ActiveCell, LookIn:=xlFormulas,
_
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
_
MatchCase:=False).Activate

instead of "testname" is it possible for this to reference whatever
value has been entered in the search cell?

I would be grateful for any pointers.
 
Try this :-

'---------------------------------------
Sub FIND_NAME()
'- enter name in cell A1 and run this macro
Dim MyName As String
MyName = ActiveSheet.Range("A1").Value
Sheets("Sheet2").Activate
Sheets("Sheet2").Cells.Find(What:=MyName, _
LookAt:=xlPart, MatchCase:=False).Activate
End Sub
'------------------------------------------
 
Cells.Find(What:=Sheets("Sheet1").Range("A1").Value,
After:=ActiveCell, LookIn:=xlFormulas, etc...
 
Having used the following how do I amend it so that if the search fails
to find the name in column B of Sheet2 it goes on to check column B of
Sheet3?

Sub FIND_NAME()

Dim MyName As String
MyName = ActiveSheet.Range("A1").Value
Sheets("Sheet2").Activate
Sheets("Sheet2").Cells.Find(What:=MyName, _
LookAt:=xlPart, MatchCase:=False).Activate

End Sub
 
Back
Top