J
jeff.white
I'm trying to use a search box in excel vba with a wildcard. My sheet
list about 1000 employees with among other things there job title.
What I'd to do is have the search box use a wildcard to search and
then delete those that do not match. The code I have so far is:
Sub DeleteRows()
Dim JobTitle, FinDate As Date, LastRow&, i&
MsgBox ("Use this routine will DELETE many rows in your Excel Sheet,
proceed with CAUTION!!")
JobTitle = InputBox("Enter Job Title Below - Caution ROWS will be
deleted!!!!!")
LastRow = Cells(Rows.Count, 12).End(xlUp).Row
For i = LastRow To 2 Step -1
If Cells(i, 12).Value <> JobTitle & "*" Then
Rows(i).Delete
End If
Next i
End Sub
An example of a job title would be: Branch Manager, Branch Manager I,
Branch Manager II and so on. I would like enter: 'Branch' (without
the quote marks of course) and have all those job titles that start
with Branch remain while the other rows get deleted. As is, all rows
get deleted. Any ideas?
list about 1000 employees with among other things there job title.
What I'd to do is have the search box use a wildcard to search and
then delete those that do not match. The code I have so far is:
Sub DeleteRows()
Dim JobTitle, FinDate As Date, LastRow&, i&
MsgBox ("Use this routine will DELETE many rows in your Excel Sheet,
proceed with CAUTION!!")
JobTitle = InputBox("Enter Job Title Below - Caution ROWS will be
deleted!!!!!")
LastRow = Cells(Rows.Count, 12).End(xlUp).Row
For i = LastRow To 2 Step -1
If Cells(i, 12).Value <> JobTitle & "*" Then
Rows(i).Delete
End If
Next i
End Sub
An example of a job title would be: Branch Manager, Branch Manager I,
Branch Manager II and so on. I would like enter: 'Branch' (without
the quote marks of course) and have all those job titles that start
with Branch remain while the other rows get deleted. As is, all rows
get deleted. Any ideas?