Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Stop Workbook from closing.

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.
  #2   Report Post  
Posted to microsoft.public.excel.programming
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.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Stop Workbook from closing.

thankyou soooo much. After all the stuffing around that I did, I can't
believe it is so simple!

To take this one step further, I would like to do the same thing if one cell
in a particular range is empty.

ie range a1:a100
if there a values in cells 1 to 50 the let it close,
if there a values in cells 1 to 90 then let it close,
but if there is a blank gap somewhere in these cells with values, then bring
up the poppup.

My mind is racing and you have helped me out tramendously, and I know I can
figure the rest out . so I don't mind if you want to leave me to learn the
rest for myself,

but If it is simple enough for you, it would save me alot of time,

thanks again for your help

melissa

"Norman Jones" wrote:

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.




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 430
Default Stop Workbook from closing.

If Range("B2:B90").SpecialCells(xlCellTypeBlanks).Sel ect = True Then
MsgBox "You have blank cells in your range"
End If


"beauty_bobaloo" wrote in message
...
thankyou soooo much. After all the stuffing around that I did, I can't
believe it is so simple!

To take this one step further, I would like to do the same thing if one
cell
in a particular range is empty.

ie range a1:a100
if there a values in cells 1 to 50 the let it close,
if there a values in cells 1 to 90 then let it close,
but if there is a blank gap somewhere in these cells with values, then
bring
up the poppup.

My mind is racing and you have helped me out tramendously, and I know I
can
figure the rest out . so I don't mind if you want to leave me to learn the
rest for myself,

but If it is simple enough for you, it would save me alot of time,

thanks again for your help

melissa

"Norman Jones" wrote:

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.






  #5   Report Post  
Posted to microsoft.public.excel.programming
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:A100") '<<==== CHANGE

If Application.CountA(rng) < rng.Cells.Count Then
MsgBox "An entry is required in ALL cells in " _
& rng.Address(0, 0, , 1)
Cancel = True
End If

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


---
Regards,
Norman


"beauty_bobaloo" wrote in message
...
thankyou soooo much. After all the stuffing around that I did, I can't
believe it is so simple!

To take this one step further, I would like to do the same thing if one
cell
in a particular range is empty.

ie range a1:a100
if there a values in cells 1 to 50 the let it close,
if there a values in cells 1 to 90 then let it close,
but if there is a blank gap somewhere in these cells with values, then
bring
up the poppup.

My mind is racing and you have helped me out tramendously, and I know I
can
figure the rest out . so I don't mind if you want to leave me to learn the
rest for myself,

but If it is simple enough for you, it would save me alot of time,

thanks again for your help

melissa





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Stop Workbook from closing.

thankyou for all your help, I guess it was lazy of me to ask you to do the
rest for me,

I have figured it out now, but I would' have been able to do it without your
help

melissa

"beauty_bobaloo" wrote:

thankyou soooo much. After all the stuffing around that I did, I can't
believe it is so simple!

To take this one step further, I would like to do the same thing if one cell
in a particular range is empty.

ie range a1:a100
if there a values in cells 1 to 50 the let it close,
if there a values in cells 1 to 90 then let it close,
but if there is a blank gap somewhere in these cells with values, then bring
up the poppup.

My mind is racing and you have helped me out tramendously, and I know I can
figure the rest out . so I don't mind if you want to leave me to learn the
rest for myself,

but If it is simple enough for you, it would save me alot of time,

thanks again for your help

melissa

"Norman Jones" wrote:

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.




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
close workbook without closing excel and stop recursive function chris Excel Discussion (Misc queries) 3 July 10th 06 08:23 PM
STOP WORKBOOK CLOSING KandK Excel Discussion (Misc queries) 2 May 5th 06 09:40 AM
Validation to stop workbook closing Jonathan Excel Discussion (Misc queries) 2 March 31st 06 11:35 AM
Stop the prompt to save when closing workbooks Rebecca Potter Excel Discussion (Misc queries) 1 December 2nd 05 10:00 AM
closing excel after closing a workbook CWalsh[_2_] Excel Programming 3 January 21st 04 03:33 PM


All times are GMT +1. The time now is 07:08 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"