how to quit in BeforeClose

P

Peter

Hi.

(Excel 2010)
I need to check if the user has changed the name at the actual sheet
before the workbook is closed.

In my sub Workbook_BeforeClose(Cancel As Boolean)
I have a YesNo box. The intention is, that if the user select No the
workbook shall remain open, e.g. the sub shall not be executed.

How do I do ?

Regards

Peter
 
D

Don Guillett

Hi.

(Excel 2010)
I need to check if the user has changed the name at the actual sheet
before the workbook is closed.

In my sub Workbook_BeforeClose(Cancel As Boolean)
I have a YesNo box. The intention is, that if the user select No the
workbook shall remain open, e.g. the sub shall not be executed.

How do I do ?

Regards

Peter

As ALWAYS, post your efforts for comments and suggestions.
 
P

Peter

Hi.

I did find a way:


Sub Workbook_BeforeClose(Cancel As Boolean)

a = MsgBox("Fik du rettet navnet på det nye ark ?", vbYesNo)
If a = vbNo Then Cancel = True

end sub

Thank you

Peter
 
G

GS

Peter expressed precisely :
Hi.

I did find a way:


Sub Workbook_BeforeClose(Cancel As Boolean)

a = MsgBox("Fik du rettet navnet på det nye ark ?", vbYesNo)
If a = vbNo Then Cancel = True

end sub

Thank you

Peter

Congratulations!!! That's exactly how it's done...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top