Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2
Default alert before deleting contents of a cell

Is there a way to make excel alert me before deleting the contents of a cell?
In other words, if I select a cell and hit delete, I want excel to ask
something like this, "Are you sure you want to delete the contents of this
cell. Yes or No".

Thanks in advance
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,090
Default alert before deleting contents of a cell

Excel doesn't know that a cell has been cleared until it has been cleared.
What you can do is use a Worksheet_Change event macro that would, if the
cell is blank, issue a Undo command to restore the previous value, then
display a message box asking you whatever, and clear the cell if you say
Yes. Essentially, Excel would be doing what you asked for but in a
round-about way. Post back if this sounds like what you want and need help
with it. Include more detail about what cells you want this to operate on.
Note that you cannot setup the macro to operate on all files and all sheets.
You can set it up on a one sheet basis or on a one file basis. HTH Otto
"Mortgage Man" wrote in message
...
Is there a way to make excel alert me before deleting the contents of a
cell?
In other words, if I select a cell and hit delete, I want excel to ask
something like this, "Are you sure you want to delete the contents of this
cell. Yes or No".

Thanks in advance



  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2
Default alert before deleting contents of a cell

This does sound like what I need, but I have never worked with macros and
would be grateful for some help with them. I am trying to make a weekly
calendar with the days of the week across the top row and the times of each
day down the left side column. This will be used for scheduling appointments
in a CPA office. We want the macro to operate on cells B4:G30. Basically we
want the program to alert us before deleting the contents of a cell so that
we do not accidentally erase an appointment.

Thanks

"Otto Moehrbach" wrote:

Excel doesn't know that a cell has been cleared until it has been cleared.
What you can do is use a Worksheet_Change event macro that would, if the
cell is blank, issue a Undo command to restore the previous value, then
display a message box asking you whatever, and clear the cell if you say
Yes. Essentially, Excel would be doing what you asked for but in a
round-about way. Post back if this sounds like what you want and need help
with it. Include more detail about what cells you want this to operate on.
Note that you cannot setup the macro to operate on all files and all sheets.
You can set it up on a one sheet basis or on a one file basis. HTH Otto
"Mortgage Man" wrote in message
...
Is there a way to make excel alert me before deleting the contents of a
cell?
In other words, if I select a cell and hit delete, I want excel to ask
something like this, "Are you sure you want to delete the contents of this
cell. Yes or No".

Thanks in advance




  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,090
Default alert before deleting contents of a cell

The following 2 macros will do what you want. Watch out for line wrapping
in these newsgroup messages. The line in the second macro that starts with
"If MsgBox..." must end with "The _". These macros must be placed in the
sheet module of your sheet. To access that module, right-click on the sheet
tab, select View Code, and paste these macros into that module. "X" out of
the module to return to your sheet. If you wish, email me and I'll send you
the small file I used for this with the code properly placed. My email
address is . Remove the "nop" from this address. HTH
Otto
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count 1 Then Exit Sub
If Intersect(Target, Range("B4:G30")) Is Nothing Then Exit Sub
If Not IsEmpty(Target) Then Exit Sub
Call QueryDelete(Target)
End Sub

Sub QueryDelete(TheCell As Range)
Dim NewValue As String
Dim OldValue As String
NewValue = TheCell.Value
Application.EnableEvents = False
Application.Undo
OldValue = TheCell.Value
If MsgBox("Are you sure you want to delete the contents of this
cell?", 20, "Confirm Deletion") = vbYes Then _
TheCell.ClearContents
Application.EnableEvents = True
End Sub

"Mortgage Man" wrote in message
...
This does sound like what I need, but I have never worked with macros and
would be grateful for some help with them. I am trying to make a weekly
calendar with the days of the week across the top row and the times of
each
day down the left side column. This will be used for scheduling
appointments
in a CPA office. We want the macro to operate on cells B4:G30. Basically
we
want the program to alert us before deleting the contents of a cell so
that
we do not accidentally erase an appointment.

Thanks

"Otto Moehrbach" wrote:

Excel doesn't know that a cell has been cleared until it has been
cleared.
What you can do is use a Worksheet_Change event macro that would, if the
cell is blank, issue a Undo command to restore the previous value, then
display a message box asking you whatever, and clear the cell if you say
Yes. Essentially, Excel would be doing what you asked for but in a
round-about way. Post back if this sounds like what you want and need
help
with it. Include more detail about what cells you want this to operate
on.
Note that you cannot setup the macro to operate on all files and all
sheets.
You can set it up on a one sheet basis or on a one file basis. HTH Otto
"Mortgage Man" wrote in message
...
Is there a way to make excel alert me before deleting the contents of a
cell?
In other words, if I select a cell and hit delete, I want excel to ask
something like this, "Are you sure you want to delete the contents of
this
cell. Yes or No".

Thanks in advance






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
Cell References [email protected] Excel Discussion (Misc queries) 2 November 15th 06 11:37 PM
Selectively Clearing cell contents jdd Excel Worksheet Functions 2 April 22nd 06 04:06 AM
Using contents of a cell in a formula Mike Excel Discussion (Misc queries) 4 June 9th 05 03:10 AM
Possible Lookup Table Karen Excel Worksheet Functions 5 June 8th 05 09:43 PM
Can I use the contents of a cell to satisfy the result_vector arg. robh_2 Excel Worksheet Functions 3 February 24th 05 08:14 PM


All times are GMT +1. The time now is 10:36 PM.

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

About Us

"It's about Microsoft Excel"