I am using macros in excel to make fields mandatory in excel workbook. However, the problem is that the workbook contains multiple worksheets and the macro applies to all th
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Dim shX As Worksheet
Dim rX As Range
Set shX = ThisWorkbook.Worksheets("Sheet1")
Set rX = shX.Cells(5, 2)
If rX = "" Then
MsgBox "Please fill cell B5"
Cancel = True
shX.Select
rX.Select
End If
End Sub