I'm creating a macro to help the user delete a row through a textBox. The user needs to click on the Eliminar hallazgo (Delete Finding) button.
Then, a form with an empty text box appears for the user to write the number of the row that will be deleted.
If a user writes an Int, the Macro runs OK (I have no idea on how to optimize it). But when a user writes something different the Macro crashes.
I would like to have a MsgBox popping up that says something like "Please enter a valid number" whenever the user writes anything different.
So far, this is my code:
Private Sub AceptarButton_Click()
Dim row2Empty As Integer, rangoDel As Range
' Asignar valor escrito por usuario a Variable
row2Empty = TextFila.Value
On Error GoTo InvalidValue:
Exit Sub
Worksheets(5).Activate
If TextFila.Value = True Then
Worksheets(5).Rows(row2Empty).Select
Worksheets(5).Rows(row2Empty).Delete
End If
Unload Me
InvalidValue:
MsgBox "Por favor digite un numero."
Resume Next
End Sub
I'm really confused on how to handle that error.
Thanks in advance,
Jaime