Re : Calcul de nombre de jours dans un USF
Re,
Je propose ce code (qui gere aussi les cellules vides pour eviter les NA) :
Private Sub ComboBox1_Change()
Dim cherch As String, derlign As Long
derlign = Sheets("DATA").Range("A65536").End(xlUp).Row
cherch = ComboBox1
Set cell = Sheets("DATA").Range("A2:A" & derlign).Find(cherch, lookAt:=xlWhole)
If Not cell Is Nothing Then
TextBoxD_CH1.Value = cell.Offset(0, 1)
TextBoxD_CH2.Value = cell.Offset(0, 2)
TextBoxD_CH3.Value = cell.Offset(0, 3)
If TextBoxD_CH1 <> "" Then
TxtBxECH1 = Round(CDate(TextBoxD_CH1) - Now)
TxtBxECH1.ForeColor = IIf(TxtBxECH1 < 30, &HFF00&, &HFF&)
Else
TxtBxECH1 = ""
End If
If TextBoxD_CH2 <> "" Then
TxtBxECH2 = Round(CDate(TextBoxD_CH2) - Now)
TxtBxECH2.ForeColor = IIf(TxtBxECH2 < 30, &HFF00&, &HFF&)
Else
TxtBxECH2 = ""
End If
If TextBoxD_CH3 <> "" Then
TxtBxECH3 = Round(CDate(TextBoxD_CH3) - Now)
TxtBxECH3.ForeColor = IIf(TxtBxECH3 < 30, &HFF00&, &HFF&)
Else
TxtBxECH3 = ""
End If
End If
End Sub
Voir le fichier joint