Good afternoon everyone,
Could somebody please help me to get the macros below to work together. I came across this code that logs all changes and additions to cells on a sheet. I then introduced a second macro that prevents access to certain columns on the sheet, but unfortunately it will not work because apparently I have introduced two Worksheet Change events. This has got a little bit out of my depth so any help would be greatly appreciated.
Option Explicit
Public OldValue As String
Private Sub Worksheet_Change(ByVal Target As Range)
Dim sSheetName As String
sSheetName = "Reporting"
Sheets("Log Details").Unprotect Password:="Emsa1249!"
Sheets("Log Details").Range("A" & Rows.Count).End(xlUp).Offset(1, 0).Value = ActiveSheet.Name & " ? " & Target.Address(0, 0)
Sheets("Log Details").Range("A" & Rows.Count).End(xlUp).Offset(0, 1).Value = OldValue
Sheets("Log Details").Range("A" & Rows.Count).End(xlUp).Offset(0, 2).Value = Target.Value
Sheets("Log Details").Range("A" & Rows.Count).End(xlUp).Offset(0, 3).Value = Environ("username")
Sheets("Log Details").Range("A" & Rows.Count).End(xlUp).Offset(0, 4).Value = Now
Sheets("Log Details").Range("A" & Rows.Count).End(xlUp).Offset(0, 5).Hyperlinks.Add Anchor:=Sheets("Log Details").Range("A" & Rows.Count).End(xlUp).Offset(0, 5), _
Address:="", SubAddress:=sSheetName & "!" & Target.AddressLocal, TextToDisplay:=sSheetName & "!" & Target.AddressLocal
Sheets("Log Details").Columns("A:F").AutoFit
Application.EnableEvents = False
Application.EnableEvents = True
Sheets("Log Details").Protect Password:="*******"
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
On Error Resume Next
OldValue = Target.Value
End Sub
The following macro is just what I want but it only works on its own.
'Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Column = 3 Or Target.Column = 6 Or Target.Column = 9 Then
Beep
Cells(Target.Row, Target.Column).Offset(0, 1).Select
End If
End Sub
Kind regards,
Potty Ash
Bookmarks