helri
04-08-2017 18:41:57
Boa tarde Fórum!
Estou tentando fazer um macro\vba no excel para controle de alterações. Essa planilha vai ser usado no meu financeiro, que diariamente acessa umas 15 pessoas diferentes. Meu problema hoje é mostra o que foi alterado, segue o código que uso hoje, se preferirem, anexei ele também.
Private Sub Workbook_Open()
End Sub
Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
Dim wsHist As Worksheet, Rng As Range
Set wsHist = Sheets("Historico")
' Let Application.ScreenUpdating = False
' Let Sheets("History").Visible = True
If Sh Is wsHist Then Exit Sub
Set Rng = wsHist.Range("A" & Rows.Count).End(xlUp).Offset(1)
With Rng
Let .Value = Now ' Data e hora
Let .Offset(, 1) = Sh.Name ' Aba
Let .Offset(, 2) = Sh.Application.UserName ' Usuario
Let .Offset(, 3) = Environ("computername") ' Maquina
Let .Offset(, 4) = Target.Address ' Célula
Let .Offset(, 5) = ActiveCell.Text ' Antes de alterado
Let .Offset(, 6) = Target.Formula ' Depois de alterado
End With
Let Application.ScreenUpdating = True
Let Sheets("Historico").Visible = True
End Sub
Estou tentando fazer um macro\vba no excel para controle de alterações. Essa planilha vai ser usado no meu financeiro, que diariamente acessa umas 15 pessoas diferentes. Meu problema hoje é mostra o que foi alterado, segue o código que uso hoje, se preferirem, anexei ele também.
Private Sub Workbook_Open()
End Sub
Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
Dim wsHist As Worksheet, Rng As Range
Set wsHist = Sheets("Historico")
' Let Application.ScreenUpdating = False
' Let Sheets("History").Visible = True
If Sh Is wsHist Then Exit Sub
Set Rng = wsHist.Range("A" & Rows.Count).End(xlUp).Offset(1)
With Rng
Let .Value = Now ' Data e hora
Let .Offset(, 1) = Sh.Name ' Aba
Let .Offset(, 2) = Sh.Application.UserName ' Usuario
Let .Offset(, 3) = Environ("computername") ' Maquina
Let .Offset(, 4) = Target.Address ' Célula
Let .Offset(, 5) = ActiveCell.Text ' Antes de alterado
Let .Offset(, 6) = Target.Formula ' Depois de alterado
End With
Let Application.ScreenUpdating = True
Let Sheets("Historico").Visible = True
End Sub