• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Worksheet_Change Event

Martyn Pattison

New Member
Hi.... Would appreciate any direction on how to integrate two events under the Worksheet_Change, or any alternative path I should consider?

I am no Excel expert and whilst quite happy with my current learning curve, I cannot get my head around what I read on this subject.

The attached file has one Event under JobData, I would like to try and integrate the code under the Sheet Event 2.

Appreciate any help.

Thanks
 

Attachments

So do you need it?
Rich (BB code):
Option Explicit
Private OldValue    As Variant

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    Dim Comm        As Comment
    If Target.CountLarge > 1 Then Exit Sub
    OldValue = Target.Value    ' Selected Cell Value

    For Each Comm In ActiveSheet.Comments
        Comm.Delete
    Next Comm

    ShowCellHistory
End Sub

Private Sub Worksheet_Change(ByVal Target As Range)
    Dim OldVal      As Variant

    If Target.CountLarge > 1 Then Exit Sub
    Application.EnableEvents = False

    On Error Resume Next
    OldVal = Target.Value
    On Error GoTo 0

    If Target.Column = 8 Then

        If Target.Validation.Type = xlValidateList Then
            Target.Offset(0, 1).ClearContents
        End If

    End If

    With ChangeLog

        Dim LogRow  As Long
        LogRow = .Cells(.Rows.Count, "A").End(xlUp).Row + 1

        .Cells(LogRow, "A").Value = Now                  ' Current Date & Time

        '         .Cells(LogRow, "B").Value = Environ("Username")       ' Computer user
        '         .Cells(LogRow, "B").Value = Users.Range("I2").Value   ' Application Username

        .Cells(LogRow, "C").Value = Me.Name              ' Sheet Name
        .Cells(LogRow, "D").Value = Target.Address       ' Cell Address
        .Cells(LogRow, "E").Value = OldVal               ' Old Value
        .Cells(LogRow, "F").Value = Target.Value         ' New value
    End With

    Application.EnableEvents = True
End Sub
 
Back
Top