Deny change of value of two target cells / enforce use of macros.
I have a macro that runs upon the change of the contents of a cell within a
particular column. The macro basically logs the user time, date and value
change input and pastes this information into another worksheet. I have two
queries.
1. If a value is pasted into more than one cell the macro does not work.
How is it possible to deny the user the possibility of pasting a value into
multiple cells? Is there something I can do with the Target.Count line at
the top?
2. Is it possible to force the user to activate the macros upon opening the
workbook so that the workbook cannot be changed without it being logged.
I decided against the share workbooks/log changes option as this would
require continual management of changes.
Thanks in advance.
Ade P
My script is currently:
Sub Worksheet_Change(ByVal Target As Range)
Dim old_Val As Variant
Dim new_Val As Variant
Dim Sheet_Name As Variant
If Target.Column = 10 Then
If Target.Count 1 Then Exit Sub
Application.ScreenUpdating = False
On Error GoTo ErrHandler
Application.EnableEvents = False
new_Val = Target.Value
Sheet_Name = ActiveSheet.Name
Application.Undo
old_Val = Target.Value
Target.Value = new_Val
' // Various other instructions here //
ErrHandler:
Application.EnableEvents = True
End If
Application.ScreenUpdating = True
End Sub
|