Hi Guys,
I am trying to write a code that will prompt me about missing fields.
For example I have 2 columns. What I want the message box to show is that "Rudy","Jerry" and "Tom" age is missing. Rudy is only shown once and not should be displayed as " Jerry & Rudy & Rudy & Tom have missing age. I tried to write my code as it would show msgbox per name with missingage, but It did not work and I realized it would be better for the prompt to show in one message box.
Column J Column K
Name Age
Gio 15
Jerry (blank)
Rudy (blank)
Rudy (blank)
Tom (blank)
Bob 20
here's my code
I would really appreciate if someone can check it or even write a new code all over as I think my codes are messed up. Thanks!!!
I am trying to write a code that will prompt me about missing fields.
For example I have 2 columns. What I want the message box to show is that "Rudy","Jerry" and "Tom" age is missing. Rudy is only shown once and not should be displayed as " Jerry & Rudy & Rudy & Tom have missing age. I tried to write my code as it would show msgbox per name with missingage, but It did not work and I realized it would be better for the prompt to show in one message box.
Column J Column K
Name Age
Gio 15
Jerry (blank)
Rudy (blank)
Rudy (blank)
Tom (blank)
Bob 20
here's my code
HTML:
Sub TEST()
Dim MissingAge As Range
Dim Name As Range
Dim Name2 As Range
Dim LastRow As Integer
LastRow = Cells(Rows.Count, "J").End(xlUp).Row
For Each MissingAge In Range("K2", Range("K" & LastRow).End(xlUp))
If IsEmpty(MissingAge) = False Then 'Do Nothin
Else
If Name2 Is Nothing Then
Set Name= MissingAge.Offset(0, -1)
MsgBox "Do you want to proceed?", vbYesNo + vbQuestion, Name+ " has missing Age"
If vbYes Then
Set Name2= Name
'Do Nothing
Else
Exit Sub
End If 'End If vbYes
Else
If Name= Name2Then
'Do Nothing
Else
MsgBox "Do you want to proceed?", vbYesNo + vbQuestion, Name+ " has missing Age"
If vbYes Then
Set Name2= Name
'Do Nothing
Else
Exit Sub
End If
End If
End If
End If
Next MissingAge
End Sub
I would really appreciate if someone can check it or even write a new code all over as I think my codes are messed up. Thanks!!!