I currently used this code attached to a command button to search and find employees in my company by their surname
although the row now includes both names and other details, is there a way I can still only search for the surname?
The surname is in every 7th cell along (starting at E1... L1... S1 ect)
Would there be any way to set the range for every 7th cell in the row ?
Sub Find_Name()
Dim intColumn As Integer
Dim strBox As String
Dim rFind As Range
Dim intRow As Integer
intRow = ActiveCell.Row
strBox = InputBox("Enter the name you want to search for.")
If strBox = "" Then Exit Sub
Set rFind = Rows("1:1").Find(What:=strBox, LookIn:=xlValues, LookAt:=xlPart)
If Not rFind Is Nothing Then
rFind.Select
intColumn = ActiveCell.Column
Cells(intRow, intColumn).Select
Else
MsgBox ("That name could not be found")
End If
End Sub
Bookmarks