combine two worksheet_change

  • Hi guys, how I can combine this two code for worsheet_change?


    Code
    /CODE FOR COLUMN O/
    Private Sub Worksheet(ByVal Target As Range)
    On Error Resume Next    With Target    If .CountLarge > 1 Or .Column <> 15 Then Exit Sub        .ClearComments        On Error GoTo 0        .AddComment        .Comment.Text Text:="Recepcionado el " & Format(Date, "long date") & " por: " & Application.UserName        .Comment.Visible = True    End With
    End Sub
    
    /CODE FOR COLUMN P/
    Private Sub Worksheet_2(ByVal Target As Range)
    On Error Resume Next    With Target    If .CountLarge > 1 Or .Column <> 16 Then Exit Sub        .ClearComments        On Error GoTo 0        .AddComment        .Comment.Text Text:="Confirmado el: " & Format(Date, "long date") & " por: " & Application.UserName        .Comment.Visible = True    End With
    End Sub
  • Try

    Code
    Private Sub Worksheet_Change(ByVal Target As Range)
        With Target
            If .Count > 1 Then Exit Sub
            If .Column = 15 Or .Column = 16 Then
                .ClearComments
                .AddComment "Recepcionado el " & Format(Date, "long date") & " por: " & Application.UserName
                .Comment.Visible = 1
            End If
        End With
    End Sub

    We now have a reputation system in place. If my reply helped please "Like" the reply by clicking the "Like" icon at bottom right of my reply.

    Edited once, last by KjBox ().

  • Hi Kjbox thanks for you answer, but the problems its that i need differents messages on column O and P i forget say this

  • Sorry, missed that. Try

    We now have a reputation system in place. If my reply helped please "Like" the reply by clicking the "Like" icon at bottom right of my reply.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!