1. Te paso la macro con la corrección del id no definido en el horario
Sub controlasis()
'calcula control de asistencia
'Por.dam
cuenta4 = 0
cuenta2 = 0
j = 2
'columnas de salida
s1 = "C"
s2 = "D"
s3 = "E"
s4 = "F"
Set h1 = Sheets("Hoja1")
Set h2 = Sheets("IO")
Set h3 = Sheets("Id incompleto")
Set h4 = Sheets("horarios")
h2.Cells.Clear
h3.Cells.Clear
h1.Select
'Range(s1 & ":" & s4).Clear
h1.Columns("A:B").Select
Selection.Sort Key1:=Range("A2"), Order1:=xlAscending, _
Key2:=Range("B2"), Order2:=xlAscending, _
Header:=xlGuess, OrderCustom:=1, _
MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal, DataOption2:=xlSortNormal
id_ant = h1.Range("A2")
fe_ant = Left(h1.Range("B2"), 10)
'Pone I/O
For i = 2 To h1.Range("A" & Rows.Count).End(xlUp).Row
hora = Mid(h1.Cells(i, "B"), 12, 2)
minu = Mid(h1.Cells(i, "B"), 15, 2)
horario = TimeSerial(hora, minu, 0)
idencontrado = 0
For m = 2 To h4.Range("A" & Rows.Count).End(xlUp).Row
gt1 = h1.Cells(i, "A")
gt2 = Weekday(Left(h1.Cells(i, "B"), 10), 1)
If h4.Cells(m, "A") = h1.Cells(i, "A") And _
h4.Cells(m, "B") = Weekday(Left(h1.Cells(i, "B"), 10), 1) Then
in1 = h4.Cells(m, "D")
in2 = h4.Cells(m, "F")
me1 = h4.Cells(m, "G")
me2 = h4.Cells(m, "I")
me3 = h4.Cells(m, "J")
me4 = h4.Cells(m, "L")
fi1 = h4.Cells(m, "M")
fi2 = h4.Cells(m, "O")
idencontrado = 1
End If
Next
h2.Cells(i, "A") = h1.Cells(i, "A")
h2.Cells(i, "B") = h1.Cells(i, "B")
If idencontrado = 1 Then
Select Case Weekday(Left(h1.Cells(i, "B"), 10), 1)
Case 1 'Domingo
Case 2, 3, 4, 5, 6, 7 'Lun, mar, mie, jue, vie, sab
Select Case horario
Case in1 To in2
h2.Cells(i, s1) = "I"
Case me1 To me2
h2.Cells(i, s1) = "O"
Case me3 To me4
h2.Cells(i, s1) = "I"
Case fi1 To fi2
h2.Cells(i, s1) = "O"
Case Else
h2.Cells(i, s1) = "Fuera de horario"
End Select
End Select
Else
h2.Cells(i, s1) = "Id no definido en el horario"
End If
Next
'Calcula la asistencia
For i = 2 To h1.Range("A" & Rows.Count).End(xlUp).Row + 1
If id_ant = h1.Cells(i, "A") And _
fe_ant = Left(h1.Cells(i, "B"), 10) Then
Select Case Weekday(fe_ant, 1)
Case 1 'Domingo
Case 2, 3, 4, 5, 6 'Lun, mar, mie, jue, vie
cuenta4 = cuenta4 + 1
Case 7 'Sabado
cuenta2 = cuenta2 + 1
End Select
Else
Select Case Weekday(fe_ant, 1)
Case 1 'Domingo
Case 2, 3, 4, 5, 6 'Lun, mar, mie, jue, vie
If cuenta4 <> 4 Then
'ejecutar dia_laboral_incompleto()
h3.Cells(j, s2) = id_ant
h3.Cells(j, s3) = fe_ant
h3.Cells(j, s4) = "Id incompleto"
j = j + 1
End If
Case 7 'Sabado
If cuenta2 <> 2 Then
'ejecutar dia_sabado_incompleto()
h3.Cells(j, s2) = id_ant
h3.Cells(j, s3) = fe_ant
h3.Cells(j, s4) = "Id incompleto"
j = j + 1
End If
End Select
id_ant = h1.Cells(i, "A")
fe_ant = Left(h1.Cells(i, "B"), 10)
cuenta4 = 1
cuenta2 = 1
End If
Next
MsgBox "proceso terminado", vbInformation
Range("A1").Select
End Sub
2. Para aplicar los cambios a la macro para que funcione con 2 archivos . podrías finalizar esta pregunta y crear una nueva
Saludos. Dam