Sub RemoveAnimal()
Dim AnimalID As Variant
Dim FindAnimal As Range
Dim ws As Worksheet
Dim sName As String
Set ws = Worksheets("Index")
sName = InputBox(Prompt:="Enter Name of Animal to Delete", _
Title:="Remove Animal")
If sName = "" Then Exit Sub
With ws.Range("A2:A" & ws.Rows.Count)
Set FindAnimal = .Find(sName, , , xlWhole)
If Not FindAnimal Is Nothing Then
MsgBox "Clicking yes will permanently delete " & FindAnimal & " and its associated data.", _
vbYesNo, "Warning"
If vbYes Then FindAnimal.EntireRow.Delete
Sheets("FindAnimal").Delete
Else
MsgBox Prompt:="Animal Not Found, Unable to Delete.", Title:="Failed"
Exit Sub
End If
End With
Application.ScreenUpdating = True
End Sub
That is the code, what is in bold is the area im having trouble with. It will delete the entire row that the search function finds, but it errors on the part where I want it to delete the sheet. I have tried other code such as having it select the sheet first, then delete the active sheet, if I dont write the If Then statement as you see it there, It wont even run the macro. I am not very good at this stuff, I am just learning.