ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   cell verification (https://www.excelbanter.com/excel-discussion-misc-queries/160483-cell-verification.html)

Firkins

cell verification
 
I have a sheet that when users input data in column N they need to put a
reason in column O. How can I ensure that the reason in entered in column O
before they save and close?

Bob Umlas

cell verification
 
Right-click the excel LOGO near the File menu, select View code, paste this
in:

Private Sub Workbook_BeforeClose(Cancel As Boolean)
If Application.CountA(Sheets("Sheet1").Range("N:N")) <
Application.CountA(Sheets("Sheet1").Range("O:O")) Then
Cancel = True
MsgBox "Before this file can be saved, each item in column N must
have a reason in column O.", vbExclamation
End If
End Sub

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
If Application.CountA(Sheets("Sheet1").Range("N:N")) <
Application.CountA(Sheets("Sheet1").Range("O:O")) Then
Cancel = True
MsgBox "Before this file can be saved, each item in column N must
have a reason in column O.", vbExclamation
End If
End Sub

Bob Umlas
Excel MVP
"Firkins" wrote in message
...
I have a sheet that when users input data in column N they need to put a
reason in column O. How can I ensure that the reason in entered in column
O
before they save and close?




Bob Umlas

cell verification
 
Make the first Msgbox I suggested say "...can be closed..." instead of
"...can be saved..."
Bob Umlas
Excel MVP

"Firkins" wrote in message
...
I have a sheet that when users input data in column N they need to put a
reason in column O. How can I ensure that the reason in entered in column
O
before they save and close?





All times are GMT +1. The time now is 08:42 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com