Excel VBA Assistance Needed with Userform, Listbox Selection, and Action if ListBox Selection Not Made

I have an excel worksheet database from which VBA userform routine loads each record.  I want the user to make a listbox selection on each record which is recorded back to the Excel worksheet before allowing movement to the next record.  I want to prompt the user with a message that a selection must be made before moving to the next record.  I am new to VBA and everything I try ends up in an infinite loop when responding to the message.  The Subs are shown below.  Please help and thank you for your assistance.  The code is below and the file is attached.

Private Sub NextRec_Click()
lastrow = 15
currentrow = currentrow + 1
ListBox1.ListIndex = -1
If currentrow = lastrow Then
MsgBox "You have answered the last question"
End If
Dom.Text = Cells(currentrow, 1)
AssessText.Text = Cells(currentrow, 2)
Subcat.Text = Cells(currentrow, 3)
Maturity.Text = Cells(currentrow, 4)
Decstate.Text = Cells(currentrow, 5)
Cells(currentrow, 6) = ListBox1.Text
If ListBox1.ListIndex = -1 Then
MsgBox ("You must make a selection before proceeding")
End If

End Sub
FFIEC-Tool-Expert-Exchange-Copy.xlsm
mcarsonsrAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Subodh Tiwari (Neeraj)Excel & VBA ExpertCommented:
You may try something like this to see if this helps....

Private Sub NextRec_Click()
Dim i As Long, cnt As Long, Ans As String
With ListBox1
       For i = 0 To .ListCount - 1
           If .Selected(i) Then
                Ans = .List(i)
               cnt = cnt + 1
           End If
       Next i
End With
If cnt = 0 Then
    MsgBox "You have to select an option from the List before navigating to the Next Record.", vbExclamation, "No Option Selected..."
    Exit Sub
End If
Cells(currentrow, 6).Value = Ans
lastrow = 15
currentrow = currentrow + 1
ListBox1.ListIndex = -1
If currentrow - 1 = lastrow Then
MsgBox "You have answered the last question"
Unload Me
End If
Dom.Text = Cells(currentrow, 1)
AssessText.Text = Cells(currentrow, 2)
Subcat.Text = Cells(currentrow, 3)
Maturity.Text = Cells(currentrow, 4)
Decstate.Text = Cells(currentrow, 5)
End Sub

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mcarsonsrAuthor Commented:
Brilliant!!   Thank you very much
Subodh Tiwari (Neeraj)Excel & VBA ExpertCommented:
You're welcome. Glad to help. :)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.