heeft iemand idee om de Worksheet_Change codes 1 van te maken?
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim xRng As Range
Dim xValue1 As String
Dim xValue2 As String
If Target.Count > 1 Then Exit Sub
On Error Resume Next
Set xRng = Cells.SpecialCells(xlCellTypeAllValidation)
If xRng Is Nothing Then Exit Sub
Application.EnableEvents = False
If Not Application.Intersect(Target, xRng) Is Nothing Then
xValue2 = Target.Value
Application.Undo
xValue1 = Target.Value
Target.Value = xValue2
If xValue1 <> "" Then
If xValue2 <> "" Then
If xValue1 = xValue2 Or _
InStr(1, xValue1, ", " & xValue2) Or _
InStr(1, xValue1, xValue2 & ",") Then
Target.Value = xValue1
Else
Target.Value = xValue1 & ", " & xValue2
End If
End If
End If
End If
Application.EnableEvents = True
End Sub
------------------------------------------------------------------------------------------------------------------------------------------------
Dim PreviousValue
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Value <> PreviousValue Then
x = Environ("USERNAME") & "|" & Application.UserName & "|" & " changed cell " & "|" & ActiveSheet.Name & Target.Address _
& "|" & PreviousValue & "|" & Target.Value & "|" & Date & "|" & Time
Sheets("logboek").Cells(65000, 1).End(xlUp).Offset(1, 0).Resize(1, 8).Value = Split(x, "|")
End If
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
PreviousValue = Target.Value
End Sub