Modificar código para que se ejecute en demás hojas
Como puedo modificar este código para que se ejecute en las siguientes hojas
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim n As Integer, Columnas As Variant
If Not Intersect(Target, Range("Q6:Q" & Range("Q6").End(xlDown).Row)) Is Nothing Then
Columnas = Array(0, 25, 27, 29, 31)
Application.EnableEvents = False
For n = 1 To Len(Target)
BuscarÁrea n, Mid(Target, n, 1), 5, 14, CInt(Columnas(n))
BuscarÁrea n, Mid(Target, n, 1), 18, 27, CInt(Columnas(n))
Next
Application.EnableEvents = True
End If
End Sub
Private Sub BuscarÁrea(n As Integer, Número As Integer, x1 As Long, x2 As Long, y As Integer)
Application.ScreenUpdating = False
y = (n - 1) * 2 + 25 'empieza en col E
aTablas:
Range(Cells(x1, y), Cells(x2, y)).Interior.ColorIndex = xlNone
For x = x1 To x2
If Cells(x, y) = Número Then
Cells(x, y).Interior.Color = vbYellow
'pasa a la tbla siguiente
GoTo siguenTablas
End If
Next
siguenTablas:
'sigue con otras tablas
y = y + 9
If y > 77 Then Exit Sub
GoTo aTablas
End Sub
1 respuesta
Respuesta de ricohablador
1
