Control de cambios

Calvuch, te cuento que tengo una macro para el control de cambios de una base de datos, pero me registra los cambios de todo el libro y solo quiero que me controle los cambios de una sola hoja. Me pudes ayudar por fa.
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
Dim Z As Range
 If Sh.Name = "Historico" Then Exit Sub
 If Target.Cells.Count > 1 Then Exit Sub
 If Not Intersect(Target, Range("A1:R3000")) Is Nothing Then
  Set Z = Range("Historico!A1").CurrentRegion
  Range("Historico!A" & Z.Rows.Count + 1).Value = Time
  Range("Historico!B" & Z.Rows.Count + 1).Value = Target.Address
  Range("Historico!C" & Z.Rows.Count + 1).Value = IIf(Target = "", "DEL", Target.Value)
 End If
End Sub
gracias

1 respuesta

Respuesta
1
Prueba esto, modifique la linea
 If Sh.Name = "Historico" Then Exit Sub
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
Dim Z As Range
 If ActiveSheet.Name <> "Historico" Then Exit Sub
 If Target.Cells.Count > 1 Then Exit Sub
 If Not Intersect(Target, Range("A1:R3000")) Is Nothing Then
  Set Z = Range("Historico!A1").CurrentRegion
  Range("Historico!A" & Z.Rows.Count + 1).Value = Time
  Range("Historico!B" & Z.Rows.Count + 1).Value = Target.Address
  Range("Historico!C" & Z.Rows.Count + 1).Value = IIf(Target = "", "DEL", Target.Value)
 End If
End Sub
 If ActiveSheet.Name <> "Historico" Then Exit Sub
indica que si la hoja activa en donde se realizo el cambio tien un nombre distinto a "Historico" entonces no registre el cambio, registrando asi solo los cambio de la hoja "Historico"
Bye
una correcion al codigo anterior , olvidate de If ActiveSheet.Name <> "Historico" Then Exit Sub
utiliza  If Sh.Name <> "Historico" Then Exit Sub
de esta manera solo captara los cambio en historico, sorry pero hoy no fue bueno el desayuno, ja,ja,ja

Añade tu respuesta

Haz clic para o

Más respuestas relacionadas