Como hacer que una macro de autosuma se repita en otra celda de la misma hoja?

Option Explicit
Dim valor As Long
Dim cantidadVeces As Integer

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$B$142" Then
cantidadVeces = cantidadVeces + 1
If cantidadVeces > 1 Then
Exit Sub
End If
valor = valor + Sheets("IA").Range("B142").Value
Sheets("IA").Range("B142").Value = valor
End If
End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
valor = 0
cantidadVeces = 0
If Target.Address = "$B$142" Then
valor = Sheets("IA").Range("B142").Value
End If
End Sub

Añade tu respuesta

Haz clic para o