Macro se pasta despues de cierto tiempo

Saludos
He estado trabajando en esta macro, pero despues de un cierto tiempo se pasma, y si le quito la funcion copiar y pegar nunca se pasma me pueden ayudar?
Worksheets("Hoja4").Activate
Range("B2").Select
For y = 2 To 27555
siguiente:
Range("B" & y).Select
If (ActiveCell.Value = "rene") Or (ActiveCell.Value = "jorge") Or (ActiveCell.Value = "kimba") Or (ActiveCell.Value = "anna") Or (ActiveCell.Value = "mauricio") Or (ActiveCell.Value = "diego") Or (ActiveCell.Value = "luis") Or (ActiveCell.Value = "carlos") Or (ActiveCell.Value = "estrella") Then
'If (ActiveCell.Value = "estrella") Then
ActiveCell.Copy
Range("C" & y).Select
If (ActiveCell.Value = "2") Then 'dia
Range("D" & y).Select
If (ActiveCell.Value = "6") Then 'horario
Range("E" & y).Select
If (ActiveCell.Value = "oficina2") Then ' oficina
Range("H" & y).Select
If (ActiveCell.Value = "copiado") Then
ElseIf (ActiveCell.Value = "") Then
ActiveCell.Value = "copiado"
Worksheets("asistencia").Activate
For celda = 12 To 100
Range("E" & celda).Select
If (ActiveCell.Value = "") Then
ActiveCell.PasteSpecial
'ActiveCell.Value = "estrella"
Worksheets("Hoja4").Activate
GoTo siguiente
Exit For
End If
Next celda
End If
End If
End If
End If
End If
Next y
si tambien me la pueden optimisar estaria mejor, de ante mano muchisimas gracias por su tiempo

1 Respuesta

Respuesta
1
Prueba el codigo :
Worksheets("Hoja4"). Activate
Range("B2").Select
For y = 2 To 27555
siguiente:
Range("B" & y).Select
If (ActiveCell.Value = "rene") Or (ActiveCell.Value = "jorge") Or (ActiveCell.Value = "kimba") Or (ActiveCell.Value = "anna") Or (ActiveCell.Value = "mauricio") Or (ActiveCell.Value = "diego") Or (ActiveCell.Value = "luis") Or (ActiveCell.Value = "carlos") Or (ActiveCell.Value = "estrella") Then
'If (ActiveCell.Value = "estrella") Then
ActiveCell.Copy
If Range("C" & y) = "2" Then 'dia
If Range("D" & y) = "6" Then 'horario
If Range("E" & y) = "oficina2" Then ' oficina
If Range("H" & y) = "copiado" Then
ElseIf Range("H" & y) = "" Then
Range("H" & y) = "copiado"
Worksheets("asistencia").Activate
For celda = 12 To 100
Range("E" & celda).Select
If Range("E" & celda) = "" Then
'ActiveCell.PasteSpecial
Range("E" & celda) = Range("B" & y)
'ActiveCell.Value = "estrella"
Worksheets("Hoja4").Activate
GoTo siguiente
Exit For
End If
Next celda
End If
End If
End If
End If
End If
Next y
Otro codigo creo que un poco mas resumido podría ser ( creo que tambien funcionara):
Los dos estan sin probarlos, pero pienso que puede funcionar así. Haz las pruebas y me comentas...
If (ActiveCell.Value = "rene") Or (ActiveCell.Value = "jorge") Or (ActiveCell.Value = "kimba") Or (ActiveCell.Value = "anna") Or (ActiveCell.Value = "mauricio") Or (ActiveCell.Value = "diego") Or (ActiveCell.Value = "luis") Or (ActiveCell.Value = "carlos") Or (ActiveCell.Value = "estrella") Then
If Range("C" & y) = "2" And Range("D" & y) = "6" And Range("E" & y) = "oficina2" Then
If Range("H" & y) = "copiado" Then
ElseIf Range("H" & y) = "" Then
Range("H" & y) = "copiado"
Worksheets("asistencia").Activate
For celda = 12 To 100
Range("E" & celda).Select
If Range("E" & celda) = "" Then
Range("E" & celda) = Range("B" & y)
Worksheets("Hoja4").Activate
GoTo siguiente
Exit For
End If
Next celda
End If
End If
End If

Añade tu respuesta

Haz clic para o

Más respuestas relacionadas