hi
I'm new to VBA, but I managed to get this code to work on another sheet, but using it in a new sheet I obviously have to change the range it is searching within (Highlighted in Italics) It needs to be changed to search the entire workbook.
Any help?
Private Sub cmdFind_Click()
On Error GoTo NotFound
Sheets("Matrix").Range("B6").Select
Range(Selection, Selection.End(xlToRight)).Select
strName = InputBox(Prompt:="Enter name of Sub Contractor.", _
Title:="ENTER SUB CONTRACTOR", Default:="Sub Contractor")
If strName = "Sub Contractor" Or strName = vbNullString Then
MsgBox ("No Name Entered")
Exit Sub
End If
Selection.Find(What:=strName, After:=ActiveCell, LookIn:= _
xlValues, LookAt:=xlPart, SearchOrder:=xlByColumns, SearchDirection:= _
xlNext, MatchCase:=False).Activate
ActiveCell.Select
Exit Sub
NotFound: MsgBox ("Sub Contractor Not found")
Exit Sub
End Sub
I'm new to VBA, but I managed to get this code to work on another sheet, but using it in a new sheet I obviously have to change the range it is searching within (Highlighted in Italics) It needs to be changed to search the entire workbook.
Any help?
Private Sub cmdFind_Click()
On Error GoTo NotFound
Sheets("Matrix").Range("B6").Select
Range(Selection, Selection.End(xlToRight)).Select
strName = InputBox(Prompt:="Enter name of Sub Contractor.", _
Title:="ENTER SUB CONTRACTOR", Default:="Sub Contractor")
If strName = "Sub Contractor" Or strName = vbNullString Then
MsgBox ("No Name Entered")
Exit Sub
End If
Selection.Find(What:=strName, After:=ActiveCell, LookIn:= _
xlValues, LookAt:=xlPart, SearchOrder:=xlByColumns, SearchDirection:= _
xlNext, MatchCase:=False).Activate
ActiveCell.Select
Exit Sub
NotFound: MsgBox ("Sub Contractor Not found")
Exit Sub
End Sub