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: 287
Default Application.undo runtime error '1004'

Hi,

I am using a vba code to track changes made to a spreadsheet on another
sheet.

Code:
================================================== ===
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
If ActiveSheet.Name = "Changelog" Then Exit Sub
Application.EnableEvents = False

UserName = Environ("USERNAME")

Sheets("Changelog").Unprotect ("test")
NewVal = Target.Value
Application.Undo
oldVal = Target.Value

lr = Sheets("Changelog").Range("A" & Rows.Count).End(xlUp).Row + 1
Sheets("Changelog").Range("A" & lr) = Now
Sheets("Changelog").Range("B" & lr) = ActiveSheet.Name
Sheets("Changelog").Range("C" & lr) = Target.Address
Sheets("Changelog").Range("D" & lr) = oldVal
Sheets("Changelog").Range("E" & lr) = NewVal
Sheets("Changelog").Range("F" & lr) = UserName
Target = NewVal
Application.EnableEvents = True

Sheets("Changelog").Protect DrawingObjects:=True, Contents:=True,
Scenarios:=True, Password:="test"


End Sub

================================================== =


My problem is I can't figure out how to code to where the user is able to
add/delete rows. Currently when someone tries to add or delete a row they
will receive a Run Time error '1004'.

I tried an If Activesheet.EntireRow.Insert then statement but that failed
miserably.
If I can track additions and deletions of rows, great, but if all changes
are tracked except for the adding/deleting of rows, that would suffice.

Thanks in advance.


 
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
runtime error '1004' application or object defined error Janis Excel Programming 4 November 18th 09 03:01 PM
Runtime error 1004 on an application.count statement PhilM[_2_] Excel Programming 1 February 27th 08 03:36 PM
runtime error '1004' application or object defined error. Please help deej Excel Programming 0 August 1st 07 09:26 AM
Runtime error 1004- application defined or object defined error Jim Thomlinson[_5_] Excel Programming 0 February 6th 06 09:33 PM
Runtime Error 1004 -- Application Defined or Object Defined Error John[_51_] Excel Programming 3 September 4th 03 04:28 PM


All times are GMT +1. The time now is 09:10 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"