Help with Code
This gets more bizare!
I looked for spaces or formulas from previous data deletions (I had deleted
all rows to row 65M...). There were none.
I created a new sheet with all formulas etc re-typed. I put in each formula
one column at a time in row 19. I tested it for several rows on each and it
worked perfectly. I also made sure there were no links to other workbooks.
I then entered this formula in column P
=IF(ISERROR(MATCH(D19,$I$16:$N$16,0)),D19,"").
This checks for an account number in the list and enters the account number
from Col D if it doesn't match the defaults. If I test this for four rows it
throws up the prompt message as before. The strange thing is, I have
commented out the error trap as below. So how does it find the code to run
the message? The only difference is that if the response to overwriting data
is "NO", the code fails and brings up the "End" or "Debug" option. This also
has the effect of turning off macros and Excel needs to be restarted. I made
sure no other workbooks were open or macros (other than Personal Macro Book)
were in action/available.
So would you like to see the workbook in its entirety?
--
Jim
Private Sub Worksheet_Change(ByVal target As Range)
If target.Cells.Count 1 Then Exit Sub
If target.Column < 6 Then Exit Sub 'last data entry cell
If target.Row < 19 Then Exit Sub 'starting row
'If target.Offset(0, 1).Value < "" Then
'If MsgBox("You are overwrititng existing data. Are you sure?", vbYesNo) =
vbNo Then
'Application.EnableEvents = False
'Application.Undo
'Application.EnableEvents = True
'Exit Sub
'End If
'End If
Application.EnableEvents = False
Cells(target.Row + 1, 1).Select
'MsgBox "Range" & target.Address & "was changed"
Range("g19:Q19").Copy target.Offset(0, 1).Resize(1, 8) 'formula row to copy
With Selection.Font
.ColorIndex = xlAutomatic
.TintAndShade = 0
.Size = 11
End With
ActiveCell.Offset(0, 4).Value = "Y"
Application.EnableEvents = True
End Sub
|