LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 132
Default Help with Code

I have the following code used in data entry. I use it in several insatnces
and have no problems. However, in this configuration, it will, after 4 rows,
prompt for a response to the overwriting data test even though there is no
data in the target cells. I can skip a few lines and start re-entering and
after 4 lines it asks the over writie prompt again. In other workbooks
(different purpose/design) it will go forever if there is no data to over
write. The only thing I've added is "ActiveCell.Offset(0, 4).Value = "Y"" to
create a default, and changed the starting rows etc to fit the new form
demension. Anyone with any ideas?

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
ActiveCell.Offset(0, 4).Value = "Y"

Application.EnableEvents = True

End Sub

--
Jim
 
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
split post code (zip code) out of cell that includes full address Concord Excel Discussion (Misc queries) 4 October 15th 09 06:59 PM
How can I modify my code to offset the defined range and repeat theprocedure instead of duplicating my code? [email protected] Excel Programming 4 May 29th 09 10:13 PM
Run VBA code only worksheet change, but don't trigger worksheet_change event based on what the code does ker_01 Excel Programming 6 October 3rd 08 09:45 PM
Protect Sheet with code, but then code will not Paste error. How do i get around this. Please read for explainations.... Corey Excel Programming 4 November 25th 06 04:57 AM
Excel code convert to Access code - Concat & eliminate duplicates italia Excel Programming 1 September 12th 06 12:14 AM


All times are GMT +1. The time now is 11:14 AM.

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"