Hi ,
I have some really good vba code which works brilliantly to log changes to a hidden Log Sheet.
Time, name, sheet name, old value and new value.
Stores all changes flawlessly however a VBA error needs fixing "Run-time error 13 type mismatch
I'm guessing something like Error handling needs putting in place but my VBA Skill base is still in the learning stages and I need a little support
Can anyone help please?
Everything is fine until a user selects more than one cell at a time on any worksheet, the code then breaks. (files attached - VBA Password is: Test - Capital T)
https://drive.google.com/file/d/0B6rF_bjMGY5pVXFFYk1YZnVwTG8/view?usp=sharing
I have some really good vba code which works brilliantly to log changes to a hidden Log Sheet.
Time, name, sheet name, old value and new value.
Stores all changes flawlessly however a VBA error needs fixing "Run-time error 13 type mismatch
I'm guessing something like Error handling needs putting in place but my VBA Skill base is still in the learning stages and I need a little support
Can anyone help please?
Everything is fine until a user selects more than one cell at a time on any worksheet, the code then breaks. (files attached - VBA Password is: Test - Capital T)
https://drive.google.com/file/d/0B6rF_bjMGY5pVXFFYk1YZnVwTG8/view?usp=sharing
Dim oldValue As String
Dim oldAddress As String
Private Sub Workbook_Open()
Sheets("LogDetails").Visible = xlSheetVeryHidden
End Sub
Private Sub Workbook_SheetBeforeDoubleClick(ByVal Sh As Object, ByVal Target As Range, Cancel As Boolean)
On Error Resume Next
If Sheets("LogDetails").Visible = xlSheetVisible Then
Sheets("LogDetails").Visible = xlSheetVeryHidden
Else
Sheets("LogDetails").Visible = xlSheetVisible
End If
Target.Offset(1, 1).Select
End Sub
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
Dim sSheetName As String
sSheetName = "WC 28.08.2016"
sSheetName = "WC 21.08.2016"
sSheetName = "WC 14.08.2016"
If ActiveSheet.Name <> "LogDetails" Then
Application.EnableEvents = False
Sheets("LogDetails").Range("A" & Rows.Count).End(xlUp).Offset(1, 0).Value = ActiveSheet.Name & " - " & Target.Address(0, 0)
Sheets("LogDetails").Range("A" & Rows.Count).End(xlUp).Offset(0, 1).Value = oldValue
Sheets("LogDetails").Range("A" & Rows.Count).End(xlUp).Offset(0, 2).Value = Target.Value
Sheets("LogDetails").Range("A" & Rows.Count).End(xlUp).Offset(0, 3).Value = Environ("username")
Sheets("LogDetails").Range("A" & Rows.Count).End(xlUp).Offset(0, 4).Value = Now
Sheets("LogDetails").Hyperlinks.Add Anchor:=Sheets("LogDetails").Range("A" & Rows.Count).End(xlUp).Offset(0, 5), Address:="", SubAddress:="'" & sSheetName & "'!" & oldAddress, TextToDisplay:=oldAddress
Sheets("LogDetails").Columns("A:D").AutoFit
Application.EnableEvents = True
End If
End Sub