rbi
New Member
- Joined
- Oct 3, 2009
- Messages
- 7
I'm terribly new to VBA and am struggling. I'm thinking this should be simple but I've searched the questions forum and don't see anything close. (Maybe too basic). I have a sheet with multiple rows of data. I'm trying to create a form that prompts for a line number that the user would like to delete from the form. The line numer comes from the data and is not the rownumber. What I've created sort of works but with quirks. I get the "Invalid Entry" msgbox even when a line is deleted. I'm hoping someone can offer advice & mentoring. Here's userform procedure code. Thanks for giving this a look-see. Ron I.
Private Sub cmdDelLine_Click()
Dim intData As Integer
Dim strData As String
Dim DelRow As Integer
strData = UserInput.Value
If IsNumeric(strData) = True Then
If strData <> 0 Then
intData = CInt(strData)
DelRow = intData + 13
ActiveSheet.Unprotect
Rows(DelRow).EntireRow.Delete
ActiveSheet.Protect
Unload Me
End If
End If
DelRecord.Hide
MsgBox "Invalid Entry, Please Re-Enter"
UserInput = ""
DelRecord.Show
End Sub
Private Sub cmdDelLine_Click()
Dim intData As Integer
Dim strData As String
Dim DelRow As Integer
strData = UserInput.Value
If IsNumeric(strData) = True Then
If strData <> 0 Then
intData = CInt(strData)
DelRow = intData + 13
ActiveSheet.Unprotect
Rows(DelRow).EntireRow.Delete
ActiveSheet.Protect
Unload Me
End If
End If
DelRecord.Hide
MsgBox "Invalid Entry, Please Re-Enter"
UserInput = ""
DelRecord.Show
End Sub