I have some code here using an inputbox to get some data. I want the inputbox to loop until user closes it. But when I close the inputbox, I get my message popup that says "Serial Number Already Exists". I'm not sure what I'm missing to not get that to popup when closing the inputbox.
Private Sub OptionButton1_Click()
'Outgoing
Dim ws As Worksheet
Set ws = Worksheets("CRR")
Dim OutPO As String
Dim Outgoing
OutPO = InputBox("Enter Outgoing PO Number", "PO")
If OutPO = "" Then
MsgBox "Enter PO Before Scanning", vbCritical, ""
Exit Sub
End If
Do
Outgoing = InputBox("Enter Outgoing CCA Serial Number!", "Outgoing")
With Sheets("CRR").Range("B:B")
Set Rng = .Find(What:=Outgoing, _
After:=.Cells(.Cells.Count), _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
If Not Rng Is Nothing Then
MsgBox "Serial Number Already Exists!", vbExclamation, "Error"
Else
Dim lRow As Long
lRow = ws.Range("A" & ws.Rows.Count).End(xlUp).Offset(1).Row
ws.Cells(lRow, 1).Value = OutPO
ws.Cells(lRow, 2).Value = Outgoing
ws.Cells(lRow, 3).Value = Date
ws.Cells(lRow, 4).Value = Environ("Username")
End If
End With
Loop Until Len(Outgoing) = 0
End Sub