I'm pretty amateur at coding, but I'm trying to develop some automated business sheets in excel to make my old man's life a little easier on the business. The intent is to create a table with range based on a number in a userform. Code looks like this: (textbox1 was renamed to nParc)
Private Sub Cmb1_Click()
Dim nP As Variant
nP = UserForm1.nParc.Value
If nP = "" Then
MsgBox "Error 0"
ElseIf Not IsNumeric(nP) Then
MsgBox "Error 1"
ElseIf Not nP > 0 Then
MsgBox "Error 2"
ElseIf nP <> Int(nP) Then
MsgBox "Error 3"
Else
ActiveSheet.ListObjects.Add(xlSrcRange, Range(Cells(1, 1).Address(), Cells(nP, 14).Address()), xlYes).Name = "Business"
End If
End Sub
I always get
Error 3
when I click the "Proceed" button, no matter what. If I remove the msgbox "error 3" and the else after, it works.
I have already tried using ElseIf Not nP = Int(nP), but the issue remains.
Any help would be deeply appreciated.