|
|
|
|
Bonjour,
J'ai un souci avec des comparaisons de dates...
L'utilisateur saisi un intervalle du type:
"de 30/12/2005 à 02/01/2006"
Et j'aimerais faire en sorte que si une cellule contient une date comprise dans cet intervalle alors çà fait quelque chose.
Pour l'instant j'ai mis des MsgBox pour vérifier:
LaDerniere = Application.Workbooks(fichier(4)).Worksheets("Tableau").Cells(65536, choix).End(xlUp).Row
temps = Split(mot_clef, " ")
date1 = temps(1)
date2 = temps(3)
MsgBox (date1)
MsgBox (date2)
For i = 20 To LaDerniere
If date1 < Application.Workbooks(fichier(4)).Worksheets("Tableau").Cells(i, choix).Value Then
MsgBox ("plus grand que " & date1 & "")
End If
If Application.Workbooks(fichier(4)).Worksheets("Tableau").Cells(i, choix).Value < date2 Then
MsgBox ("plus petit que " & date2 & "")
End If
Dim chemin, mot_clef As String Dim valid, lancement, fin, k, choix As Integer Dim ok As Boolean Dim fso, Dossier, Flder As Object Dim fichier Dim cellule As Integer Dim Msg1, Msg2, Style, Title, Box Dim nb, derniere_colonne Dim cellul As String Dim par As Variant Dim datedeb, datefin As Date J'ai un peu changé mon code en fait...j'ai l'impression qu'on ne peut faire que ce style de comparaison avec les dates: If datefin > Application.Workbooks(fichier(4)).Worksheets("Tableau").Cells(i, choix).Value Then
mais pas çà : If datefin < Application.Workbooks(fichier(4)).Worksheets("Tableau").Cells(i, choix).Value Then
"La culture c'est comme la confiture : moins on en a plus on l'étale" |
Re:
I = 1: choix = 1
LaDerniere = Workbooks("Test.xls").Worksheets("Feuil1").Cells(65536, choix).End(xlUp).Row
mot_clef = Range("I1").Value
Temps = Split(mot_clef, " ")
DateDeb = Temps(0)
DateFin = Temps(1)
For I = 1 To LaDerniere
DateCible = FormatDateTime(Workbooks("Test.xls").Worksheets("Feuil1").Cells(I, choix).Value)
If ((DateDeb < DateCible) And (DateFin > DateCible)) Then
Workbooks("Test.xls").Worksheets("Feuil1").Cells(I, (choix + 2)).Value = ("Date comprise dans l'interval")
Else
Workbooks("Test.xls").Worksheets("Feuil1").Cells(I, (choix + 2)).Value = ("Date non-comprise dans l'interval")
End If
Next I
Lupin ~L'essentiel est invisible pour les yeux~ ~On ne voit bien qu'avec le coeur~ |
Re:
|
Re:
Dim DateDeb, DateFin As Date
Dim DateCible As Date
I = 1: choix = 1
LaDerniere = Workbooks("Test.xls").Worksheets("Feuil1").Cells(65536, choix).End(xlUp).Row
mot_clef = Range("I1").Value
Temps = Split(mot_clef, " ")
DateDeb = FormatDateTime(Temps(0))
DateFin = FormatDateTime(Temps(1))
For I = 1 To LaDerniere
DateCible = FormatDateTime(Workbooks("Test.xls").Worksheets("Feuil1").Cells(I, choix).Value)
If ((DateDeb < DateCible) And (DateFin > DateCible)) Then
Workbooks("Test.xls").Worksheets("Feuil1").Cells(I, (choix + 2)).Value = ("Date comprise dans l'interval")
Else
Workbooks("Test.xls").Worksheets("Feuil1").Cells(I, (choix + 2)).Value = ("Date non-comprise dans l'interval")
End If
Next I
Lupin ~L'essentiel est invisible pour les yeux~ ~On ne voit bien qu'avec le coeur~ |