Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Dia As Byte, Mes As Byte, Col As Integer, Fil As Long, _
Trab As String, Tipo As String
If Target.Address = "$E$2" Then
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Application.EnableEvents = False
ActiveSheet.DisplayPageBreaks = False
Dia = Day(Range("E2"))
Mes = Month(Range("E2"))
Col = Mes * 31 - 29 + Dia - 1 ' <== Esta es la parte que me era mas
' complicada de resolver, buscar
' la columna y tu ya la tenias.
Fil = 10 ' <-- Aqui indica la primera fila
' de la hoja PARTE DIARIO
With Sheets("Parte Diario")
While .Cells(Fil, "A") <> ""
Trab = .Cells(Fil, "A")
Tipo = .Cells(Fil, Col)
Call Busca_Trabajador(Trab, Tipo, "Parte Tareas")
Call Busca_Trabajador(Trab, Tipo, "Parte Tareas (2)")
Fil = Fil + 1
Wend
End With
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
Application.EnableEvents = True
ActiveSheet.DisplayPageBreaks = True
Application.CutCopyMode = False
Sheets("Parte Tareas").Select
Range("E2").Select
End If
End Sub
' </> ------------------------------------------------------------ </>
' </> ---&--- Busca el trabajador en las hojas de tareas
' </> ------------------------------------------------------------ </>
Private Sub Busca_Trabajador(Trab, Tipo, Hoja)
Dim Col As String, Fil As Integer
Col = "E" ' <-- Aqui indico la columna el primer cuadro
Fil = 5 ' <-- Aqui indico la 1ª fila de la columna
Sheets(Hoja).Select
With Sheets(Hoja)
While .Range(Col & Fil) <> ""
If UCase(.Range(Col & Fil)) = UCase(Trab) Then
.Range(Col & Fil).Select
Select Case UCase(Tipo)
Case "B": Call Color_Azul
Case "V": Call Color_Rosa
Case "N": Call Color_Verde
Case Else: Call Color_Blanco
End Select
Fil = 1 ' <--- Esto es para buscar una celda vacia y
Col = "A" ' salir del bucle
End If
Fil = Fil + 1
' Cuando acaba la primera columna salta a la segundo
If Range(Col & Fil) = "" And Col = "E" Then Col = "I": Fil = 5
' Cuando acaba la SEGUNDA columna salta a la TERCERA
If Range(Col & Fil) = "" And Col = "I" Then Col = "K": Fil = 5
Wend
End With
End Sub