![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
New Member
Join Date: Jan 2002
Posts: 9
|
I am doing something wrong. I want to clear two forms and then save the workbook upon the user attempting to close the workbook.
I keep getting an error message:Event Procedure declaration doesn't match description of event having the same name. What am I doing wrong? Private Sub Workbook_BeforeClose() 'This macro clears the supplemental form Application.ScreenUpdating = False Sheets("supplemental").Select Range("h4").Select ActiveCell.Clear Range("C14").Select ActiveCell.FormulaR1C1 = "" Range("C16").Select ActiveCell.FormulaR1C1 = "" Application.ScreenUpdating = True 'This macro clears the worksheet form Sheets("worksheet").Select Range("I4").Select ActiveCell.FormulaR1C1 = "" Range("E7").Select ActiveCell.FormulaR1C1 = "" Range("E8").Select ActiveCell.FormulaR1C1 = "" Range("E9").Select ActiveCell.FormulaR1C1 = "" Range("f7").Select ActiveCell.Clear Range("e12").Select ActiveCell.Clear Range("e15").Select ActiveCell.Clear Range("F19").Select ActiveCell.FormulaR1C1 = "" Range("G19").Select ActiveCell.FormulaR1C1 = "" Range("H19").Select ActiveCell.FormulaR1C1 = "" Range("F21").Select ActiveCell.FormulaR1C1 = "" Range("F23").Select ActiveCell.FormulaR1C1 = "" Range("H23:I23").Select ActiveCell.FormulaR1C1 = "" Range("F25").Select ActiveCell.FormulaR1C1 = "" Range("F27").Select ActiveCell.FormulaR1C1 = "" Range("F29").Select ActiveCell.FormulaR1C1 = "" Range("e31").Select ActiveCell.Clear Range("e32").Select ActiveCell.Clear Range("E34:F34").Select ActiveCell.FormulaR1C1 = "" Range("E36:F36").Select ActiveCell.FormulaR1C1 = "" Range("E38").Select ActiveCell.Clear ActiveWorkbook.save End Sub |
|
|
|
|
|
#2 |
|
New Member
Join Date: Apr 2002
Location: Lawrence, KS
Posts: 29
|
Workbook_BeforeClose(Cancel As Boolean)
see your problem now? you must include "Cancel As Boolean" as an argument, but you don't have to do anything with it. |
|
|
|
|
|
#3 |
|
New Member
Join Date: Jan 2002
Posts: 9
|
I surfed around to find what I needed and ignored the boolean comment because I didn't know what it meant.
Figures it was too simple. Thanks!! |
|
|
|
|
|
#4 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Columbus, OH, USA
Posts: 3,519
|
Quick tip as well.
When you are in the worksheet or the workbook object you can access the events pretty easily (or userforms for that matter). There are two combo boxes at the top of the VBE when you are in these modules. The one on the left lets you select any object that is part of the object, the combobox on the right lets you choose an event. (this will help you to avoid missing out arguments in the future) HTH. |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|