You are on page 1of 22

CODIGO EN VISUAL VASIC

Option Explicit
Dim valor As Long
Dim cantidadVeces As Integer
Dim valor1 As Long
Dim cantidadVeces1 As Integer
Dim valor2 As Long
Dim cantidadVeces2 As Integer
Dim valor3 As Long
Dim cantidadVeces3 As Integer
Dim valor4 As Long
Dim cantidadVeces4 As Integer
Dim valor5 As Long
Dim cantidadVeces5 As Integer
Dim valor6 As Long
Dim cantidadVeces6 As Integer
Dim valor7 As Long
Dim cantidadVeces7 As Integer
Dim valor8 As Long
Dim cantidadVeces8 As Integer
Dim valor9 As Long
Dim cantidadVeces9 As Integer
Dim valor10 As Long
Dim cantidadVeces10 As Integer
Dim valo11 As Long

Dim cantidadVeces11 As Integer


Dim valor12 As Long
Dim cantidadVeces12 As Integer
Dim valor13 As Long
Dim cantidadVeces13 As Integer
Dim valor14 As Long
Dim cantidadVeces14 As Integer
Dim valor15 As Long
Dim cantidadVeces15 As Integer
Dim valor16 As Long
Dim cantidadVeces16 As Integer
Dim valor17 As Long
Dim cantidadVeces17 As Integer
Dim valor18 As Long
Dim cantidadVeces18 As Integer
Dim valor19 As Long
Dim cantidadVeces19 As Integer

Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Address = "$G$4" Then


cantidadVeces = cantidadVeces + 1

If cantidadVeces > 1 Then


Exit Sub
End If

valor = valor + Sheets("Hoja1").Range("G4").Value


Sheets("Hoja1").Range("G4").Value = valor

End If

End Sub
Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Address = "$G$5" Then


cantidadVeces1 = cantidadVeces1 + 1

If cantidadVeces1 > 1 Then


Exit Sub
End If

valor1 = valor1 + Sheets("Hoja1").Range("G5").Value


Sheets("Hoja1").Range("G5").Value = valor1

End If

End Sub
Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Address = "$G$6" Then


cantidadVeces2 = cantidadVeces2 + 1

If cantidadVeces2 > 1 Then


Exit Sub
End If

valor2 = valor2 + Sheets("Hoja1").Range("G6").Value


Sheets("Hoja1").Range("G6").Value = valor2

End If

End Sub
Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Address = "$G$7" Then


cantidadVeces3 = cantidadVeces3 + 1

If cantidadVeces3 > 1 Then


Exit Sub
End If

valor3 = valor3 + Sheets("Hoja1").Range("G7").Value


Sheets("Hoja1").Range("G7").Value = valor3

End If

End Sub
Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Address = "$G$8" Then


cantidadVeces4 = cantidadVeces4 + 1

If cantidadVeces4 > 1 Then


Exit Sub
End If

valor4 = valor4 + Sheets("Hoja1").Range("G8").Value


Sheets("Hoja1").Range("G8").Value = valor4

End If

End Sub
Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Address = "$G$9" Then


cantidadVeces5 = cantidadVeces5 + 1

If cantidadVeces5 > 1 Then

Exit Sub
End If

valor5 = valor5 + Sheets("Hoja1").Range("G9").Value


Sheets("Hoja1").Range("G9").Value = valor5

End If

End Sub
Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Address = "$G$10" Then


cantidadVeces6 = cantidadVeces6 + 1

If cantidadVeces6 > 1 Then


Exit Sub
End If

valor6 = valor6 + Sheets("Hoja1").Range("G10").Value


Sheets("Hoja1").Range("G10").Value = valor6

End If

End Sub

Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Address = "$G$11" Then


cantidadVeces7 = cantidadVeces7 + 1

If cantidadVeces7 > 1 Then


Exit Sub
End If

valor7 = valor7 + Sheets("Hoja1").Range("G11").Value


Sheets("Hoja1").Range("G11").Value = valor7

End If

End Sub
Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Address = "$G$12" Then


cantidadVeces8 = cantidadVeces8 + 1

If cantidadVeces8 > 1 Then


Exit Sub
End If

valor8 = valor8 + Sheets("Hoja1").Range("G12").Value

Sheets("Hoja1").Range("G12").Value = valor8

End If

End Sub
Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Address = "$G$13" Then


cantidadVeces9 = cantidadVeces9 + 1

If cantidadVeces9 > 1 Then


Exit Sub
End If

valor9 = valor9 + Sheets("Hoja1").Range("G13").Value


Sheets("Hoja1").Range("G13").Value = valor9

End If

End Sub
Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Address = "$G$14" Then


cantidadVeces10 = cantidadVeces10 + 1

If cantidadVeces10 > 1 Then


Exit Sub
End If

valor10 = valor10 + Sheets("Hoja1").Range("G14").Value


Sheets("Hoja1").Range("G14").Value = valor10

End If

End Sub
Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Address = "$G$15" Then


cantidadVeces11 = cantidadVeces11 + 1

If cantidadVeces11 > 1 Then


Exit Sub
End If

valor11 = valor11 + Sheets("Hoja1").Range("G15").Value


Sheets("Hoja1").Range("G15").Value = valor11

End If

End Sub
Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Address = "$G$16" Then


cantidadVeces12 = cantidadVeces12 + 1

If cantidadVeces12 > 1 Then


Exit Sub
End If

valor12 = valor12 + Sheets("Hoja1").Range("G16").Value


Sheets("Hoja1").Range("G16").Value = valor12

End If

End Sub
Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Address = "$G$17" Then


cantidadVeces13 = cantidadVeces13 + 1

If cantidadVeces13 > 1 Then


Exit Sub
End If

valor13 = valor13 + Sheets("Hoja1").Range("G17").Value


Sheets("Hoja1").Range("G17").Value = valor13

End If

End Sub
Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Address = "$G$18" Then


cantidadVeces14 = cantidadVeces14 + 1

If cantidadVeces14 > 1 Then


Exit Sub
End If

valor14 = valor14 + Sheets("Hoja1").Range("G18").Value


Sheets("Hoja1").Range("G18").Value = valor14

End If

End Sub
Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Address = "$G$19" Then


cantidadVeces15 = cantidadVeces15 + 1

If cantidadVeces15 > 1 Then


Exit Sub
End If

valor15 = valor15 + Sheets("Hoja1").Range("G19").Value


Sheets("Hoja1").Range("G19").Value = valor15

End If

End Sub
Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Address = "$G$20" Then


cantidadVeces16 = cantidadVeces16 + 1

If cantidadVeces16 > 1 Then


Exit Sub
End If

valor16 = valor16 + Sheets("Hoja1").Range("G20").Value


Sheets("Hoja1").Range("G20").Value = valor16

End If

End Sub
Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Address = "$G$21" Then


cantidadVeces17 = cantidadVeces17 + 1

If cantidadVeces17 > 1 Then


Exit Sub
End If

valor17 = valor17 + Sheets("Hoja1").Range("G21").Value


Sheets("Hoja1").Range("G21").Value = valor17

End If

End Sub
Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Address = "$G$22" Then


cantidadVeces18 = cantidadVeces18 + 1

If cantidadVeces18 > 1 Then

Exit Sub
End If

valor18 = valor18 + Sheets("Hoja1").Range("G22").Value


Sheets("Hoja1").Range("G22").Value = valor18

End If

End Sub
Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Address = "$G$23" Then


cantidadVeces19 = cantidadVeces19 + 1

If cantidadVeces19 > 1 Then


Exit Sub
End If

valor19 = valor19 + Sheets("Hoja1").Range("G23").Value


Sheets("Hoja1").Range("G23").Value = valor19

End If

End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range)


valor = 0
cantidadVeces = 0

If Target.Address = "$G$4" Then


valor = Sheets("Hoja1").Range("G4").Value
End If

End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range)


valor1 = 0
cantidadVeces1 = 0

If Target.Address = "$G$5" Then


valor1 = Sheets("Hoja1").Range("G5").Value
End If

End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range)


valor2 = 0
cantidadVeces2 = 0

If Target.Address = "$G$6" Then


valor2 = Sheets("Hoja1").Range("G6").Value
End If

End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
valor3 = 0
cantidadVeces3 = 0

If Target.Address = "$G$7" Then


valor3 = Sheets("Hoja1").Range("G7").Value
End If

End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
valor4 = 0
cantidadVeces4 = 0

If Target.Address = "$G$8" Then


valor4 = Sheets("Hoja1").Range("G8").Value
End If

End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
valor5 = 0
cantidadVeces5 = 0

If Target.Address = "$G$9" Then


valor5 = Sheets("Hoja1").Range("G9").Value
End If

End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
valor6 = 0
cantidadVeces6 = 0

If Target.Address = "$G$10" Then


valor6 = Sheets("Hoja1").Range("G10").Value
End If

End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
valor7 = 0
cantidadVeces7 = 0

If Target.Address = "$G$11" Then

valor7 = Sheets("Hoja1").Range("G11").Value
End If

End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
valor8 = 0
cantidadVeces8 = 0

If Target.Address = "$G$12" Then


valor8 = Sheets("Hoja1").Range("G12").Value
End If

End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
valor9 = 0
cantidadVeces9 = 0

If Target.Address = "$G$13" Then


valor9 = Sheets("Hoja1").Range("G13").Value
End If

End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)

valor10 = 0
cantidadVeces10 = 0

If Target.Address = "$G$14" Then


valor10 = Sheets("Hoja1").Range("G14").Value
End If

End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
valor11 = 0
cantidadVeces11 = 0

If Target.Address = "$G$15" Then


valor11 = Sheets("Hoja1").Range("G15").Value
End If

End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
valor12 = 0
cantidadVeces12 = 0

If Target.Address = "$G$16" Then


valor12 = Sheets("Hoja1").Range("G16").Value
End If

End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
valor13 = 0
cantidadVeces13 = 0

If Target.Address = "$G$17" Then


valor13 = Sheets("Hoja1").Range("G17").Value
End If

End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
valor14 = 0
cantidadVeces14 = 0

If Target.Address = "$G$18" Then


valor14 = Sheets("Hoja1").Range("G18").Value
End If

End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
valor15 = 0
cantidadVeces15 = 0

If Target.Address = "$G$19" Then


valor15 = Sheets("Hoja1").Range("G19").Value
End If

End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
valor16 = 0
cantidadVeces16 = 0

If Target.Address = "$G$20" Then


valor16 = Sheets("Hoja1").Range("G20").Value
End If

End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
valor17 = 0
cantidadVeces17 = 0

If Target.Address = "$G$21" Then


valor17 = Sheets("Hoja1").Range("G21").Value
End If

End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
valor18 = 0
cantidadVeces18 = 0

If Target.Address = "$G$22" Then


valor18 = Sheets("Hoja1").Range("G22").Value
End If

End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
valor19 = 0
cantidadVeces19 = 0

If Target.Address = "$G$23" Then


valor19 = Sheets("Hoja1").Range("G23").Value
End If

End Sub

You might also like