Mandatory cell check before closure

S

Simon

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
 
R

Ron de Bruin

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
 
S

simon

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)




"Simon" <[email protected]> wrote in
message news:[email protected]...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top