Excel VBA Problem

  • Thread starter Thread starter ajlove20
  • Start date Start date
A

ajlove20

Hi,

I have been given a task from work to create a workbook with about
worksheets. The workbook will be given to a supervisor to fill ou
specific fields. When the supervisor tries to close the worksheet, i
should go through each sheet and make sure that each field that wa
supposed to be filled were completed. Then it should highlight th
fields that were not filled. The workbook should not be able to clos
until the fields are completed.

How do I attempt to take a stab at this task?

Thank you in advance.

a
 
Hi
you may use some code in the workbook_beforeclose event (see:
http://www.cpearson.com/excel/events.htm)
But this is not bullet-proof. e.g. the supervisor disables macros at
start-up.

Within this event procedure you can check if specific cells are filled
and quit the action if they are not filled. So something like

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim wks As Worksheets
Set wks = Me.Worksheets("sheet1")

With wks
If .Range("A1").Value = "" Then
MsgBox "cell A1 is not filled, closing is canceled"
Cancel = True
End If
End With
End Sub
 
Back
Top