Ir ao conteúdo
  • Cadastre-se

Nathália Xavier

Membro Júnior
  • Posts

    2
  • Cadastrado em

  • Última visita

Reputação

0
  1. Poderiam me ajudar com unificar esse dois Worksheet_Change(ByVal Target As Range) para mesma planilha: PRIMEIRO CÓDIGO Private Sub Worksheet_Change(ByVal Target As Range) On Error GoTo Tratar Dim campoAlt As String Dim valorDig As String Dim linha As Long linha = Sheets("Registro").Range("A" & Rows.Count).End(xlUp).Row + 1 valorDig = Target.Value campoAlt = Target.Address With Sheets("Registro") .Cells(linha, 1) = Now() .Cells(linha, 2) = Application.UserName .Cells(linha, 3) = valorDig .Cells(linha, 4) = ActiveSheet.Name .Cells(linha, 5) = campoAlt End With Tratar: Exit Sub SEGUNDO CÓDIGO: Private Sub Worksheet_SelectionChange(ByVal Target As Range) Cells(Target.Row + Target.Rows.Count, Target.Item(1, 1).Column).ID = Target.Address End Sub Private Sub Worksheet_Change(ByVal Target As Range) Dim nlin As Integer Dim wsRegistro As Worksheet Set wsRegistro = ThisWorkbook.Sheets("Registro") Dim LinhaRegistro As Long LinhaRegistro = wsRegistro.Cells(wsRegistro.Rows.Count, "A").End(xlUp).Row + 1 nlin = Target.Row If Target.Item(1, 1).ID <> "" Then If Target.Rows.Count > 1 Then wsRegistro.Cells(LinhaRegistro, 1).Value = Now() wsRegistro.Cells(LinhaRegistro, 2).Value = "Linhas " & nlin & " à " & nlin + Target.Rows.Count & " excluída" Else wsRegistro.Cells(LinhaRegistro, 1).Value = Now() wsRegistro.Cells(LinhaRegistro, 2).Value = "Linha " & nlin & " excluída" End If Else If Target.Rows.Count > 1 Then wsRegistro.Cells(LinhaRegistro, 1).Value = Now() wsRegistro.Cells(LinhaRegistro, 2).Value = "Linhas " & nlin & " à " & nlin + Target.Rows.Count & " inserídas" Else wsRegistro.Cells(LinhaRegistro, 1).Value = Now() wsRegistro.Cells(LinhaRegistro, 2).Value = "Linha " & nlin & " inserídas" End If End If Target.Item(1, 1).ID = "" Cells(Target.Row + Target.Rows.Count, Target.Item(1, 1).Column).ID = Target.Address End Sub

Sobre o Clube do Hardware

No ar desde 1996, o Clube do Hardware é uma das maiores, mais antigas e mais respeitadas comunidades sobre tecnologia do Brasil. Leia mais

Direitos autorais

Não permitimos a cópia ou reprodução do conteúdo do nosso site, fórum, newsletters e redes sociais, mesmo citando-se a fonte. Leia mais

×
×
  • Criar novo...

 

GRÁTIS: ebook Redes Wi-Fi – 2ª Edição

EBOOK GRÁTIS!

CLIQUE AQUI E BAIXE AGORA MESMO!