Workbook_before close: actions do not take place.. why?


Posted by Remi on February 01, 2002 1:52 AM

Hi,

I`m making a macro which copies a few cell and then pastes them in another row in the same sheet.
I want this copying to take place when people close the workbook.

The pasting works if I run the macro seperately
(so that`s piece is okay) but if I close the workbook, I do not find the pasted cell when opening it again!

See program below:
anyove who can give me some tips!?
THNKS.
Remi
Holland


Sub workbook_BeforeClose()
Range("A100:Z100").Select
Selection.Copy
Range("A93").Select
ActiveSheet.Paste
Range("A95").Select
Application.CutCopyMode = False
ActiveWorkbook.Save
End Sub

Posted by Ivan F Moala on February 01, 2002 2:23 AM

Routine should be;

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Range("A100:Z100").Select
Selection.Copy
Range("A93").Select
ActiveSheet.Paste
Range("A95").Select
Application.CutCopyMode = False
ActiveWorkbook.Save
End Sub


And should be placed in the Thisworkbook object
Alt F11
Ctrl R
Doulble click on Thisworkbook
Paste code


Ivan


Posted by Remi on February 01, 2002 5:24 AM

Private Sub Workbook_BeforeClose(Cancel As Boolean)


Posted by Remi on February 01, 2002 5:24 AM

Private Sub Workbook_BeforeClose(Cancel As Boolean)

EXCELLENT! INDEED. I was not paying enough attention thanks Ivan



Posted by JohnG on February 01, 2002 5:50 AM

Is the workbook the same as holds the macro?