My code: Dim Efound as Range EsheetDelete = InputBox(\" Please Input name of Emp
ID: 3564171 • Letter: M
Question
My code:
Dim Efound as Range
EsheetDelete = InputBox(" Please Input name of Employee Terminated ")
. . . . (code locating worksheet with employee name on it and deleting it)
Sheet3.Select
With ActiveSheet.Range("H115:H499")
Set Efound = .Find(What:=EsheetDelete, After:=.Range("H114"))
End With
Efound.EntireRow.Delete
The above five lines of code is what I'm having trouble with. On sheet3 is the same name that I would have inputted from the input box, I'm trying to locate the row number that it is on, and delete it from the list. The list is from H115 to H499, but all I'm getting when I run this code is a type mis-match error. and I can not seem to find where the error is.
Help!!
Explanation / Answer
I would do it this way
Sub somesub()
Dim EsheetDelete As String
Dim TheRow As Long
EsheetDelete = InputBox(" Please Input name of Employee Terminated ")
' . . . (code locating worksheet with employee name on it and deleting it)
Sheet3.Select
On Error Resume Next
TheRow = Application.Match(EsheetDelete, Range("H115:H445"), 0)
On Error GoTo 0
If TheRow > 0 Then
TheRow = TheRow + 114
Rows(TheRow).EntireRow.Delete
Else
MsgBox "Employee not found!"
End If
End Sub
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.