Option Explicit
'Declaración de las variables que hay en ThisWorkBook
Public celdaAnterior As Range
Public ColorAnterior As Long
'Declaración de las variables que hay en el módulo en que trabajamos
Dim b, c, d, i, cociente, residuo, residuo_2, z, x, m, l, t, w, tt, ll As Integer
Sub cancelarUP()
Application.EnableEvents = False
If Intersect(ActiveCell, Range("b5:w35")) Is Nothing Then
ActiveCell.Offset(-1).Select
Application.EnableEvents = True
End If
End Sub
Sub cancelarDOWN() 'esto es para que la celda activa no suba o baje con el up & down
Application.EnableEvents = False
If Intersect(ActiveCell, Range("b5:w35")) Is Nothing Then
ActiveCell.Offset(1).Select
Application.EnableEvents = True
End If
End Sub
Sub auto_open()
Columns("A:w").Select
Selection.ColumnWidth = 3 'representamos el ancho de filas y columnas del area de interés
'Range("A5:A35").Interior.ColorIndex = 6 'coloreamos de amarillo el borde superior
Range("A5:W5").Interior.ColorIndex = 6 'coloreamos de amarillo el borde izquierdo
Range("w5:W35").Interior.ColorIndex = 6 'coloreamos de amarillo el borde inferior
Range("A35:W35").Interior.ColorIndex = 6 'coloreamos de amarillo el borde derecho
Range("B6:V34").Interior.ColorIndex = 2 'coloreamos de blanco el área comprendida dentro de los bordes
Range("A1:z1").Clear 'cada vez que se inicializa el juevo las variables de la primera fila se borran
Range("a1:zz4").Interior.ColorIndex = 2
Cells(15, 2).Select 'la pelota empieza en la celda situada en la fila 15 y columna 2
ActiveWindow.DisplayVerticalScrollBar = False 'de esta forma se elimina la posibilidad de utilizar la barra de desplazamiento vertical
tiempo 'le dice al programa que vaya al siguiente programa llamado tiempo
End Sub
Sub tiempo()
b = Range("a1")
c = b + 1
Range("A1").Value = c
m = Range("Y1").Value
w = 1 + Range("X1").Value Mod 2
Range("Y1").Value = w
Range("Z1").Value = w Mod 2
If ActiveCell.Column = 22 Then
t = Range("x1").Value
l = t + 1
Range("X1").Value = l
End If
If ActiveCell.Column = 1 Then
tt = Range("x1").Value
ll = tt + 1
Range("w1").Value = ll
Else
If ll >= 5 Then
Range("X1").Value = 0
Range("Z1").Value = 0
Range("Y1").Value = 2
End If
End If
Application.OnTime Now + TimeValue("00:00:01"), "tiempo"
residuo = c Mod 10
cociente = c \ 10
residuo_2 = cociente Mod 2
Range("c1").Value = cociente
Range("b1").Value = residuo
Range("d1").Value = residuo_2
If Range("X1").Value < 2 And Range("Z1").Value = 1 And Range("Y1").Value = 1 Then
If ActiveCell.Column = 1 Then
Range("A1:M1").Clear
ActiveCell.Offset(-1, 1).Select
Else
If ActiveCell.Row = 34 Then
Range("H1").Value = ActiveCell.Column
ActiveCell.Offset(-1, -1).Select
Else
If ActiveCell.Column < Range("H1").Value And Range("H1").Value <> 0 And ActiveCell.Column > 1 Then
ActiveCell.Offset(-1, -1).Select
Else
If ActiveCell.Column = 22 And ActiveCell.Row > 6 Then
Range("G1").Value = ActiveCell.Row
ActiveCell.Offset(1, -1).Select
Else
If ActiveCell.Column < 22 And ActiveCell.Row > Range("G1").Value And Range("G1").Value <> 0 And ActiveCell.Column <> 1 Then
ActiveCell.Offset(1, -1).Select
Else
If ActiveCell.Column > 1 And ActiveCell.Row = 6 Then
ActiveCell.Offset(1, 1).Select
Range("F1").Value = ActiveCell.Column - 1
Else
If ActiveCell.Row > 6 And ActiveCell.Column >= Range("F1").Value And Range("F1").Value <> 0 Then
ActiveCell.Offset(1, 1).Select
Else
If ActiveCell.Column >= 1 And ActiveCell.Row > 6 And Range("F1").Value = 0 Then
ActiveCell.Offset(-1, 1).Select
End If
End If
End If
End If
End If
End If
End If
End If
End If
If Range("X1").Value < 2 And Range("Z1").Value = 0 And Range("Y1").Value = 2 Then
If ActiveCell.Row = 5 And ActiveCell.Column = 2 Then
ActiveCell.Offset(1, 1).Select
Else
If ActiveCell.Column = 1 Then
Range("A1:M1").Clear
ActiveCell.Offset(-1, 1).Select
Else
If ActiveCell.Row = 34 Then
Range("H1").Value = ActiveCell.Column
ActiveCell.Offset(-1, -1).Select
Else
If ActiveCell.Column < Range("H1").Value And Range("H1").Value <> 0 And ActiveCell.Column > 1 Then
ActiveCell.Offset(-1, -1).Select
Else
If ActiveCell.Column = 22 And ActiveCell.Row > 6 Then
Range("G1").Value = ActiveCell.Row
ActiveCell.Offset(1, -1).Select
Else
If ActiveCell.Column < 22 And ActiveCell.Row > Range("G1").Value And Range("G1").Value <> 0 And ActiveCell.Column <> 1 Then
ActiveCell.Offset(1, -1).Select
Else
If ActiveCell.Column > 1 And ActiveCell.Row = 6 Then
ActiveCell.Offset(1, 1).Select
Range("F1").Value = ActiveCell.Column - 1
Else
If ActiveCell.Row > 6 And ActiveCell.Column >= Range("F1").Value And Range("F1").Value <> 0 Then
ActiveCell.Offset(1, 1).Select
Else
If ActiveCell.Column >= 1 And ActiveCell.Row > 6 And Range("F1").Value = 0 Then
ActiveCell.Offset(-1, 1).Select
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
If Range("X1").Value >= 2 Then
If ActiveCell.Row = 6 And ActiveCell.Column = 1 Then
ActiveCell.Offset(1, 1).Select
Range("X1").Value = 1
Range("Z1").Value = 0
Range("Y1").Value = 2
Else
If ActiveCell.Row = 35 Then
Range("k1").Value = ActiveCell.Column
ActiveCell.Offset(-1, 1).Select
Range("F1").Clear
Range("I1").Clear
Range("G1").Clear
Else
If Range("X1").Value >= 2 And ActiveCell.Column = 22 Then
Range("F1").Clear
Range("I1").Clear
Range("G1").Value = 35
ActiveCell.Offset(-1, -1).Select
Else
If Range("X1").Value >= 2 And ActiveCell.Column > 1 And ActiveCell.Row > Range("I1").Value And Range("I1").Value <> 0 Then
ActiveCell.Offset(1, 1).Select
Else
If Range("X1").Value >= 2 And ActiveCell.Column = 1 And ActiveCell.Row > 6 Then
Range("G1").Value = 23
Range("I1").Value = ActiveCell.Row
ActiveCell.Offset(1, 1).Select
Else
If Range("X1").Value >= 2 And ActiveCell.Column > 1 And ActiveCell.Row = 6 Then
Range("H1").Value = ActiveCell.Column
ActiveCell.Offset(1, -1).Select
Range("F1").Value = ActiveCell.Column - 1
Else
If Range("X1").Value >= 2 And ActiveCell.Row > 6 And ActiveCell.Column <= Range("H1").Value And Range("F1").Value <> 0 Then
ActiveCell.Offset(1, -1).Select
Else
If Range("X1").Value >= 2 And ActiveCell.Column = 22 And ActiveCell.Row > 6 Then
Range("G1").Value = ActiveCell.Row
ActiveCell.Offset(-1, -1).Select
Else
If Range("X1").Value >= 2 And ActiveCell.Column < 22 And ActiveCell.Row < Range("G1").Value And ActiveCell.Column <> 1 Then
ActiveCell.Offset(-1, -1).Select
Else
If Range("X1").Value >= 2 And ActiveCell.Row < 35 And ActiveCell.Column > Range("k1").Value And ActiveCell.Column < 22 Then
ActiveCell.Offset(-1, 1).Select
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End Sub