Find the Cell address that matches my Input box reply My code: Dim Efound as Ran
ID: 3565436 • Letter: F
Question
Find the Cell address that matches my Input box reply
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 thee same name that I would have inputted from the input box, I'm trying to locate the row number that it is on, and deelete it from the list. The list is from H115 to H499, but all I'm getting when I run this codde is a type mis-match error. and I ccan not seem to find where the error is.
Explanation / Answer
Hi,
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.Seleect
On Error Resume Nextt
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 foound!"
End If
End Subbb
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.