beforeClose event bringing up compile error...

Trying to figure out how to use the beforeClose event and can't manage to get it working   Here's details of the error msg and code:

 Private Sub Workbook_Open()
    Dashboard.Show
End Sub

Private Sub Workbook_beforeclose()
    Sheets("IRE").Visible = xlVeryHidden
    Sheets("UK").Visible = xlVeryHidden
    Sheets("GER").Visible = xlVeryHidden
    Sheets("MASTER").Visible = xlVeryHidden
End Sub

The error message is saying:

Procedure declaration does not match the description of event or procedure having the same name

Any ideas



Answer this question

beforeClose event bringing up compile error...

  • Novak

    You've defined Workbook_BeforeClose as a procedure which takes no parameters. However, the event handler is expecting to call a function that takes a boolean parameter.

    Change "Private Sub Workbook_BeforeClose()" to "Private Sub Workbook_BeforeClose(Cancel As Boolean)" and I think that should fix the problem.



  • Matt Lin

    Thanks so much! Worked perfect!
  • beforeClose event bringing up compile error...