Olá Ricardo.
Troque seu código por este:
Código: Selecionar todos
Private Sub UserForm_Initialize()
Dim lFrmHdl As Long, iCount As Integer
lFrmHdl = FindWindowA(vbNullString, Me.Caption)
If lFrmHdl <> 0 Then
For iCount = 0 To 1
RemoveMenu GetSystemMenu(lFrmHdl, False), 0, MF_BYPOSITION
Next iCount
End If
frmHdl = FindWindowA(vbNullString, Me.Caption)
ExibirBarraTítulo False
Set m_Rgn = New CBMPRegion
m_Rgn.CreateFromPic Me.Picture, vbBlue
SetWindowRgn frmHdl, m_Rgn.Handle, True
Me.Repaint
Dim i As Date
i = Now
ThisWorkbook.Worksheets("Plano de Ação").Activate
Range("x2").Select
While ActiveCell.Offset(0, -2) <> "" And ActiveCell.Offset(0, 1) = ""
'Se a data do plano de ação estiver vencida
If ActiveCell.Offset(0, -2) < i Then
ActiveCell.Value = i - ActiveCell.Offset(0, -2).Value
ActiveCell.Value = Format(ActiveCell.Value, "##")
ActiveCell.Font.Bold = True
ActiveCell.Interior.ColorIndex = 3
ActiveCell.Offset(1, 0).Select
Else
'Se a data do plano de ação não estiver vencida
ActiveCell.Offset(0, 0).Value = ""
ActiveCell.Font.Bold = False
ActiveCell.Interior.ColorIndex = 2
ActiveCell.Offset(1, 0).Select
End If
'Se a data de conclusão for menor igual a data do plano de ação
If ActiveCell.Offset(0, 1) <= ActiveCell.Offset(0, -2) Then
ActiveCell.Offset(0, 0).Value = 0
ActiveCell.Font.Bold = False
ActiveCell.Interior.ColorIndex = 2
ActiveCell.Offset(1, 0).Select
Else
'Se a data de conclusão for maior que a data do plano de ação
ActiveCell.Value = ActiveCell.Offset(0, 1).Value - ActiveCell.Offset(0, -2).Value
ActiveCell.Value = Format(ActiveCell.Value, "##")
ActiveCell.Interior.ColorIndex = 3
ActiveCell.Font.Bold = True
ActiveCell.Offset(1, 0).Select
End If
If ActiveCell.Offset(0, -2) = "" Then
ActiveCell.Value = ""
ActiveCell.Font.Bold = False
ActiveCell.Interior.ColorIndex = 2
ActiveCell.Offset(1, 0).Select
End If
If ActiveCell.Offset(0, 1) <> "" Then
If ActiveCell.Offset(0, 0) = 0 Then
ActiveCell.Offset(0, 5) = "Concluída no Prazo"
Else
ActiveCell.Offset(0, 5) = "Concluída Fora do Prazo"
End If
End If
If ActiveCell.Offset(0, 1) = "" Then
If ActiveCell.Offset(0, -2) = "" Then
ActiveCell.Offset(0, 5) = "Falta Plano de Ação"
Else
If ActiveCell.Offset(0, -2) < i Then
ActiveCell.Offset(0, 5) = "Em Atrazo"
Else
ActiveCell.Offset(0, 5) = "Em Andamento"
End If
End If
End If
Wend
End Sub
Qualquer coisa poste aqui.
Abraço....