REQUIRED DATA IN CERTAIN CELLS


Posted by Dan on January 25, 2002 2:06 AM

Hi, Thanks to Juan Pablo for the coding that I need for this which I have attached below. How do I now assign this code so that when I go to save the workbook the code runs. At the moment nothing happens but the code does work when tested in Visual Basic. If anyone could help I would appreciate.

Private Sub workbook_BeforeSave()

If WorksheetFunction.CountA(Union([B5], [D5])) = 2 Then

'everything ok
Else
Cancel = True
MsgBox "Please check your form, there are fields with missing data."
End If
End Sub



Posted by Bariloche on January 25, 2002 4:30 AM

Dan,

That code needs to be in the "ThisWorkbook" code sheet. In the VB Editor, cut your code from where it is currently, double click on the "ThisWorkbook" object and paste the code in the sheet that pops up.


have fun