Bonsoir le Fil
Pouvez vous m'aider à trouver mon erreur ?
dans le fichier ci joint j'ai mis un code pour comparer deux colonnes ,il fonctionne bien .
Les deux onglets sont réellement deux fichiers séparés ,j'ai essayé de l'adapter mais il bloque sur la ligne bleu:
Merci d'avance pour votre aide
Voici mon code
Private Sub CdButOK_Click()
Dim i As Long, j As Long, plagehebdo As Range, plagejour As Range
Select Case CbBox_choixjour.Value
Case "Lundi"
'Workbooks.Open Filename:= _
'"K:\Pilotage\Camionnage\Matrice_Chauffeur.xls"
Workbooks.Open Filename:= _
"C:\Documents and Settings\Desktop\Camionnage\Heures_chauffeurs.xls"
Sheets("Hebdo").Select
ActiveSheet.Unprotect Password:="Terminal"
Set plagehebdo = Sheets("Hebdo").Range("A6:A" & Range("A65356").End(xlUp).Row)
For Each nom1 In plagehebdo
i = nom1.Row
heure1 = Sheets("Hebdo").Range("C" & i)
heure1 = Format(heure1, "hh:mm")
'Workbooks.Open Filename:= _
'"K:\Pilotage\Camionnage\Matrice_Chauffeur.xls"
Workbooks.Open Filename:= _
"C:\Documents and Settings\Desktop\Camionnage\Matrice_chauffeur.xls"
Sheets("Lundi").Select
ActiveSheet.Unprotect Password:="Terminal"
Set plagejour = Sheets("Lundi").Range("B3:B" & Range("B65356").End(xlUp).Row)
For Each nom2 In plagejour
plagejour.Select
j = nom2.Row
heure2 = Sheets("Lundi").Range("U" & j)
heure2 = Format(heure2, "hh:mm")
If nom1 = nom2 And heure1 <> heure2 Then
Range("U" & j).Interior.ColorIndex = 6 'Colorie en Jaune la cellule
Exit For
End If
Next nom2
Sheets("Lundi").Select
Next nom1
End Select
End Sub
@+
Bricoltou
Pouvez vous m'aider à trouver mon erreur ?
dans le fichier ci joint j'ai mis un code pour comparer deux colonnes ,il fonctionne bien .
Les deux onglets sont réellement deux fichiers séparés ,j'ai essayé de l'adapter mais il bloque sur la ligne bleu:
Merci d'avance pour votre aide
Voici mon code
Private Sub CdButOK_Click()
Dim i As Long, j As Long, plagehebdo As Range, plagejour As Range
Select Case CbBox_choixjour.Value
Case "Lundi"
'Workbooks.Open Filename:= _
'"K:\Pilotage\Camionnage\Matrice_Chauffeur.xls"
Workbooks.Open Filename:= _
"C:\Documents and Settings\Desktop\Camionnage\Heures_chauffeurs.xls"
Sheets("Hebdo").Select
ActiveSheet.Unprotect Password:="Terminal"
Set plagehebdo = Sheets("Hebdo").Range("A6:A" & Range("A65356").End(xlUp).Row)
For Each nom1 In plagehebdo
i = nom1.Row
heure1 = Sheets("Hebdo").Range("C" & i)
heure1 = Format(heure1, "hh:mm")
'Workbooks.Open Filename:= _
'"K:\Pilotage\Camionnage\Matrice_Chauffeur.xls"
Workbooks.Open Filename:= _
"C:\Documents and Settings\Desktop\Camionnage\Matrice_chauffeur.xls"
Sheets("Lundi").Select
ActiveSheet.Unprotect Password:="Terminal"
Set plagejour = Sheets("Lundi").Range("B3:B" & Range("B65356").End(xlUp).Row)
For Each nom2 In plagejour
plagejour.Select
j = nom2.Row
heure2 = Sheets("Lundi").Range("U" & j)
heure2 = Format(heure2, "hh:mm")
If nom1 = nom2 And heure1 <> heure2 Then
Range("U" & j).Interior.ColorIndex = 6 'Colorie en Jaune la cellule
Exit For
End If
Next nom2
Sheets("Lundi").Select
Next nom1
End Select
End Sub
@+
Bricoltou
Pièces jointes
Dernière édition: