newbie1987
New Member
- Joined
- Jun 29, 2023
- Messages
- 4
- Office Version
- 365
Hi, new here. was wondering if I could get some help on basic coding.
I am trying to create a before close event to stop someone exiting workbook before filling in certain cells. I am able to put code across 1 field but not multiple.
Code below:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
If Cells(10, 5) = "" Then
MsgBox "this field is required", vbInformation, "REQUIRED"
Cancel = True
End If
End Sub
However i need this on (10,7) and (10,8) and (10,14) (10,15) (10,16) with different messages for each.
thanks,
I am trying to create a before close event to stop someone exiting workbook before filling in certain cells. I am able to put code across 1 field but not multiple.
Code below:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
If Cells(10, 5) = "" Then
MsgBox "this field is required", vbInformation, "REQUIRED"
Cancel = True
End If
End Sub
However i need this on (10,7) and (10,8) and (10,14) (10,15) (10,16) with different messages for each.
thanks,