execute code in all 3 sheets in excel

0

Good morning experts

How can I add this code so that it executes at the same time on the 3 sheets when I make each number change in cell A1

Sub Controldenúmero1_Cambiar()
Dim n As Integer
For n = 1 To Len([A1])
BuscarÁrea n, Mid([A1], n, 1), 4, 13
BuscarÁrea n, Mid([A1], n, 1), 17, 26
Next

End Sub
'y este es el complemento

Sub BuscarÁrea(n As Integer, Número As Integer, x1 As Long, x2 As Long)
Application.ScreenUpdating = False

y = (n - 1) * 2 + 5 '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 > 57 Then Exit Sub
GoTo aTablas
End Sub

link

    
asked by Jhon Fredy Murcia Rodriguez 03.10.2018 в 00:17
source

1 answer

1

Assuming you always want to run the code on the same 3 sheets, this code will work for you. It is a loop in which you change the sheet, and execute your code:

Sub BUCLE_HOJAS()

Dim MisHojas As Variant
Dim ZZ As Byte

MisHojas = Array("actual", "anterior1", "anterior2") 'poner aquí nombre de las hojas en las que se quiera ejecutar el código

For ZZ = 0 To UBound(MisHojas) Step 1
    ThisWorkbook.Worksheets(MisHojas(ZZ)).Activate
    Controldenúmero1_Cambiar
Next ZZ

Erase MisHojas


End Sub

Put it in the same module that you have your code.

    
answered by 03.10.2018 в 15:50