View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Norman Jones Norman Jones is offline
external usenet poster
 
Posts: 5,302
Default Stop Workbook from closing.

Hi Melissa,

Try:

'=============
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim rng As Range

Set rng = Me.Sheets("Sheet1").Range("A1") '<<==== CHANGE

If IsEmpty(rng) Then
MsgBox "An entry is requires in " _
& rng.Address(0, 0, , 1)
Cancel = True
End If

End Sub
'<<=============


---
Regards,
Norman


"beauty_bobaloo" wrote in message
...
I have been playing around with running a macro before a sheet is closed,
and
I have found it very useful.
I don't know if this is possible of not, so I would apreciate your advice,

when a user attempts to close the workbook, I want my macro to run a
check,
and if a specific cell has no value in it, I want a popup to say "please
enter vallue in cell..." When the user clicks ok, instead of exiting the
workbook, I would like it to close the popup and keep the workbook open
for
the user to add a value.

I can do all of this exept the part where I want it to keep the workbook
open.
Of course as soon as you click ok the workbook closes.

Is there any way to do this, or am I just hitting my head against the
wall....?

Any help is greatly appreciated.

Melissa.