Notifications
Clear all

Registrar alteração

10 Posts
3 Usuários
0 Reactions
1,575 Visualizações
(@miguel-70)
Posts: 0
New Member
Topic starter
 

Ola pessoal, Bom dia!
Estou com dificuldade de completar este código é na ultima linha, esta dando erro que seria transferir as informações das células que foram alteradas.
Quero que ao apagar a célula as informações de data, horas e células que foram apagadas fique registrado na plan1

Sub Alteração()
ActiveCell.ClearContents
Linha = Plan1.Cells(Plan1.Rows.Count, 2).End(xlUp).Row
Plan1.Cells(Linha + 1, 2) = Now
Linha = Plan1.Cells(Plan1.Rows.Count, 3).End(xlUp).Row
Plan1.Cells(Linha + 1, 3) = Formula.Target 'erro aqui
End Sub

Obrigado.

 
Postado : 29/01/2015 8:49 am
(@fernandofernandes)
Posts: 43750
Illustrious Member
 

Boa tarde!!

Olha eu confesso que estou boiando, você deseja limpar a célula

ActiveCell.ClearContents

e copia-la para a mesma guia? mas onde?

Att

 
Postado : 29/01/2015 8:55 am
(@miguel-70)
Posts: 0
New Member
Topic starter
 

Obrigado pela atenção.
Irmão o que eu quero e que ao apagar uma célula, então registra na plan1 a data, horas e célula, neste evento.

 
Postado : 29/01/2015 9:14 am
(@fernandofernandes)
Posts: 43750
Illustrious Member
 

Boa tarde!!

Seria algo assim...?

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
'Insira esse código dentro do Módulo de Planilha
    Dim VRange As Range, cell As Range
    Dim Msg As String
    Dim ValidateCode As Variant
    Set VRange = Range("A2:A10") 'Mude caso necessario
    For Each cell In Target
        If Union(cell, VRange).Address = VRange.Address Then
            Cells(cell.Row, Columns.Count).End(xlToLeft) = Date & " " & Time
        End If
    Next cell
End Sub

Att

 
Postado : 29/01/2015 9:36 am
(@miguel-70)
Posts: 0
New Member
Topic starter
 

Neste evento, Private Sub Worksheet_Change(ByVal Target As Excel.Range) não serve porque já existe outro.
Então gostaria que fosse no próprio código, abaixo desta linha; ActiveCell.ClearContents

Sub Alteração()
ActiveCell.ClearContents 'certo
Linha = Plan1.Cells(Plan1.Rows.Count, 2).End(xlUp).Row 'certo
Plan1.Cells(Linha + 1, 2) = Now 'certo data e horas
Linha = Plan1.Cells(Plan1.Rows.Count, 3).End(xlUp).Row 'certo
Plan1.Cells(Linha + 1, 3) = Formula.Target 'erro aqui quero que leve também a formula da célula alterada 'Target.Address
End Sub

Obrigado

 
Postado : 29/01/2015 9:59 am
(@fernandofernandes)
Posts: 43750
Illustrious Member
 

Boa tarde!!

Qual problemas?
Use IF..Else para combina-los
http://stackoverflow.com/questions/1123 ... eet-change

Att

 
Postado : 29/01/2015 10:10 am
(@fernandofernandes)
Posts: 43750
Illustrious Member
 

Boa tarde!!

Já tentou algo assim?

Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, ActiveCell) Is Nothing Then Exit Sub
Application.EnableEvents = False
    Call MeChameNaWorksheet_Change
Application.EnableEvents = True
End Sub
Sub MeChameNaWorksheet_Change()
    ActiveCell.Offset(, 1) = Date & " " & Time
End Sub

Att

 
Postado : 29/01/2015 10:29 am
(@miguel-70)
Posts: 0
New Member
Topic starter
 

Bom dia a todos!
Esgotaram as minhas pesquisas e não encontrei a solução para a ultima linha do código, levar o endereço da célula apagada para a Plan1.

Sub Alteração()
ActiveCell.ClearContents
Plan1.Range("A" & ActiveSheet.Rows.Count).End(xlUp).Offset(1, 0) = Now
Plan1.Range("B" & ActiveSheet.Rows.Count).End(xlUp).Offset(1, 0) = ActiveSheet.Name
Plan1.Range("C" & ActiveSheet.Rows.Count).End(xlUp).Offset(1, 0) = Cells.Address 'FALTA LEVAR O ENDEREÇO DA CÉLULA ALTERADA
End Sub

Obrigado.

 
Postado : 01/02/2015 7:34 am
(@trindade)
Posts: 0
New Member
 

Bom dia, Miguel 70.

Da uma olhada nesse arquivo que grava toda alteração realizada na planilha em um bloco de notas se vai te ajudar.

 
Postado : 02/02/2015 7:43 am
(@miguel-70)
Posts: 0
New Member
Topic starter
 

Resolveu sim Trindade, muito obrigado

 
Postado : 02/02/2015 12:01 pm