Warn before editing in a cell containing data

  • Thread starter Thread starter fishcad
  • Start date Start date
F

fishcad

This seems like it should be an easy issue, but I can't find an answer.
I use Excel as my gradebook. I enter lots of scores everyday and
want to prevent accidentally changing data in a cell where I hav
previously entered a value. I believe that in a previous version
used I would have to press ENTER twice to change a cell value, but onl
once if the cell was empty. I am currently using Excel 2000. I hav
already unchecked the "Edit directly in cells" box
 
Hi

Right click on the sheet name tab,selct "View Code" and paste in this
code;

Dim bVal As Boolean
Private Sub Worksheet_Change(ByVal Target As Range)
Dim iReply As Integer
If bVal = True Then
Application.EnableEvents = False
iReply = MsgBox("Over write cell value", vbOKCancel +
vbQuestion)
If iReply = vbCancel Then Application.Undo
bVal = False
Application.EnableEvents = True
End If
End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
bVal = Not IsEmpty(Target)
End Sub

You will need to push Enter twice to over write any existing data.

** Posted via: http://www.ozgrid.com
Excel Templates, Training, Add-ins & Business Software Galore!
Free Excel Forum http://www.ozgrid.com/forum ***
 
Thanks for your reply. I don't know anything about so I don't know wha
to make of this. When I entered data into the first cell I got
syntax error message with the line beginning, "iReply..." highlighte
in blue. After I clicked OK that line is red and the first line i
highlighted in yellow with a yellow arrow to the left of the firs
line
 
I put the whole msgbox command in one line, got rid of the + and added
comma instead. It worked after that
 
Back
Top