
Originally Posted by
h4a4r6r6
Thank you 6StringJazzer. That's the kind of solution I'm after however when I enter something into column E and go to select a cell in column A to enter the next name, Excel hangs (not responding). Any ideas why this might be please?
You may find JeteMc's solution a better fit, as it does not require macros. However, here is a fix for the problem in mine. I neglected to turn off events so that when the code makes a selection, it calls itself infinitely.
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim R As Long
Application.EnableEvents = False
If Cells(Target.Row, "A") <> "" And Target = "" And (Target.Column = 2 Or Target.Column = 5) Then
' user is about to fill in a required field, do nothing
Else
R = 2 ' first data row
Do Until Cells(R, "A") = ""
If Cells(R, "B") = "" Then
MsgBox "You must provide " & Cells(1, "B") & " for " & Cells(R, "A") & " before continuing"
Cells(R, "B").Select
Exit Sub
ElseIf Cells(R, "E") = "" Then
MsgBox "You must provide " & Cells(1, "E") & " for " & Cells(R, "A") & " before continuing"
Cells(R, "E").Select
Exit Sub
End If
Loop
End If
Application.EnableEvents = True
End Sub
Bookmarks