Adding mandatory fields before being allowed to submit on an excel form


I have the below macro on an excel form to submit the form/send an outlook email (my email address was removed–noted in red). I have a few fields on the form that need to be mandatory before users can submit the form, but I’m having trouble finding a macro that can help. Does anyone know if there’s some sort of macro that will not allow the below macro to run until all mandatory cells have information added?


Private Sub CommandButton2_Click()

Dim OutLookApp As Object
Dim OutLookMailItem As Object
Dim myAttachments As Object

Set OutLookApp = CreateObject(“OutLook.application”)
Set OutLookMailItem = OutLookApp.CreateItem(0)
Set myAttachments = OutLookMailItem.Attachments

With OutLookMailItem
.To = “email address
.Subject = “Bio Update Form”
.Body = “Please update the attached information.”
myAttachments.Add ActiveWorkbook.FullName
End With

Set OutLookMailItem = Nothing
Set OutLookApp = Nothing

End Sub



By: Courtney

Leave a Reply

Your email address will not be published. Required fields are marked *