Multiple Private Sub

Flashback

New Member
Joined
Oct 24, 2018
Messages
6
Hello,

im VBA newb.

Please how could I combine this two sub?

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    Dim rInt As Range
    Dim rCell As Range
    Dim tCell As Range

    Set rInt = Intersect(Target, Range("AE:AE"))
    If Not rInt Is Nothing Then
        For Each rCell In rInt
            Set tCell = rCell.Offset(0, -29)
            If IsEmpty(tCell) Then
                tCell = Now
                tCell.NumberFormat = "mm.dd.yyyy"
            End If
        Next
    End If
End Sub

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    
    Dim LR     As Long
    Dim c      As Range
    Dim pval   As Variant
    
    On Error Resume Next
    
    Application.EnableEvents = False
       If Target(1).Value <> PreviousValues(Target(1).Row, Target(1).Column) Then
            With Sheets("LogSheet")
            For Each c In Target
                pval = PreviousValues(c.Row, c.Column)
                If pval <> "" Then
                    LR = .Cells(Rows.Count, "A").End(xlUp).Row + 1
                    .Cells(LR, "A").Value = ActiveSheet.Name & "!" & c.Address
                    .Cells(LR, "B").Value = Now
                    .Cells(LR, "C").Value = Environ("UserName")
                    .Cells(LR, "D").Value = pval
                    .Cells(LR, "E").Value = c.Value
                End If
            Next c
        End With
    End If
    Application.EnableEvents = True
    
End Sub

THANKS!
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).

Forum statistics

Threads
1,223,911
Messages
6,175,327
Members
452,635
Latest member
laura12345

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top