Hi
try
Code:Option Explicit Private Sub Workbook_BeforeClose(Cancel As Boolean) Dim r As Range Dim k, i As Long Dim msg As String Const MySheet = "Sheet1" '<<<<< adjust to suit Const MyRange = "A10:B45" '<<<<< adjust to suit Set r = Worksheets(MySheet).Range(MyRange) If Application.WorksheetFunction.CountA(r) Then k = r.Value2 msg = "Quantity missing in the following cell(s)" For i = 1 To UBound(k, 1) If Len(k(i, 1)) Then If Len(k(i, 2)) = 0 Then msg = msg & vbLf & vbTab & r.Cells(i, 2).Address(0, 0) End If End If Next If InStr(1, msg, Chr(10)) Then MsgBox msg, vbInformation Cancel = True End If End If End Sub




Reply With Quote
Bookmarks