Excel 2000 vs 97 code

  • Thread starter Thread starter Carl Johnson
  • Start date Start date
C

Carl Johnson

Several weeks ago I inquired in this news group about how to ensure that
when the end user closed a spreadsheet that all the data was entered. I got
an excellent response from Ron de Bruin that worked great on my machine
where I have Excel 2000 however when I took it to work it would not work,
they have '97. How can I alter the following code to get it to work on '97?
Thank you in advance.

Private sub WorkBook_Before Close(Cancel As Boolean)
If Application.WorksheetFunction.CountA(Sheets("Sheet1")
..Range("A1:A10")) < 10 Then
MgsBox "You must fill in all the cells"
Cancel = True
End If
End sub
 
The code worked fine for me in Excel 97 (after correcting a few typos so it
looked like this):

Private Sub WorkBook_BeforeClose(Cancel As Boolean)
If Application.WorksheetFunction.CountA(Sheets("Sheet1").Range("A1:A10")) <
10 Then
MsgBox "You must fill in all the cells"
Cancel = True
End If
End Sub

If this doesn't work please tell us where exactly it fails and what is the
error message.
 
Back
Top