ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Mandatory cell check before closure (https://www.excelbanter.com/excel-programming/283221-mandatory-cell-check-before-closure.html)

simon

Mandatory cell check before closure
 
Is there a way to have mandatory cells that must be
contain data being checked before the document is close
and prompting the user to complete all mandatory cells.

Many Thanks,


Simon

Ron de Bruin

Mandatory cell check before closure
 
Hi Simon

You can use the Counta function like this in the Thisworkbook module

Private Sub Workbook_BeforeClose(Cancel As Boolean)
If Application.WorksheetFunction.CountA(Sheets("Sheet 1").Range("a1:a10")) < 10 Then
MsgBox "fill in all cells"
Cancel = True
End If
End Sub

--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2002 SP-2)
www.rondebruin.nl



"Simon" wrote in message ...
Is there a way to have mandatory cells that must be
contain data being checked before the document is close
and prompting the user to complete all mandatory cells.

Many Thanks,


Simon




simon

Mandatory cell check before closure
 
This worked great.

Thank you very much.

Simon


-----Original Message-----
Hi Simon

You can use the Counta function like this in the

Thisworkbook module

Private Sub Workbook_BeforeClose(Cancel As Boolean)
If Application.WorksheetFunction.CountA(Sheets

("Sheet1").Range("a1:a10")) < 10 Then
MsgBox "fill in all cells"
Cancel = True
End If
End Sub

--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2002 SP-2)
www.rondebruin.nl



"Simon" wrote in

message ...
Is there a way to have mandatory cells that must be
contain data being checked before the document is close
and prompting the user to complete all mandatory cells.

Many Thanks,


Simon



.



All times are GMT +1. The time now is 11:23 PM.

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