Bonjour,
Je vais essayer d'être le plus claire si cela ne l’était pas, veuillez m'en excusez d'avance.
Voilà la macro que j'ai créé :
Sub Macro2()
'
'Macro2 Macro()
'
'
Sheets("Fichier AC43").Select
Cells.Select
If Not Worksheets("Fichier AC43").AutoFilterMode Then
ActiveWorkbook.Worksheets("Fichier AC43").Range("A1:CK30000").AutoFilter
End If
For Each Ligne In Worksheets("Fichier AC43").Range("2:65535").Rows
If Ligne.Cells(1, 42).Value = "43" Then
ActiveWorkbook.Worksheets("Fichier AC43").AutoFilter.Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Fichier AC43").AutoFilter.Sort.SortFields.Add( _
Range("P1"), xlSortOnFontColor, xlAscending, , xlSortNormal).SortOnValue.Color _
= RGB(255, 0, 0)
With ActiveWorkbook.Worksheets("Fichier AC43").AutoFilter.Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
RowFin = Range("AX2").End(xlDown).Row
Range(Range("AN2"), Range("AX" & RowFin)).Select
Selection.Copy
Range("N2").Select
ActiveSheet.Paste
End If
Next
For Each Ligne In Worksheets("Fichier AC43").Range("2:65535").Rows
If Ligne.Cells(1, 68).Value = "43" Then
ActiveWorkbook.Worksheets("Fichier AC43").AutoFilter.Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Fichier AC43").AutoFilter.Sort.SortFields.Add( _
Range("P1"), xlSortOnFontColor, xlAscending, , xlSortNormal).SortOnValue.Color _
= RGB(0, 176, 240)
With ActiveWorkbook.Worksheets("Fichier AC43").AutoFilter.Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End If
If Ligne.Font.Color = RGB(0, 176, 240) Then
RowFin = Range("BX2").End(xlDown).Row
Range(Range("BN2"), Range("BX" & RowFin)).Select
Selection.Copy
Range("N2").Select
ActiveSheet.Paste
End If
Next
Cells.Select
With Selection.Font
.ColorIndex = xlAutomatic
.TintAndShade = 0
End With
End Sub
Le problème survient lors de la ligne If Ligne.Font.Color = RGB(0, 176, 240) et de la condition dessous car à ce moment la macro ne fait rien, il n'effectue pas le copier coller alors que la condition est remplie. Et si je retire cette condition, la macro me copie les cellules BN à BX qui ne correspondent pas à des lignes de couleur de police bleue et donc ma mise en forme n'est pas bonne.
Pourriez vous donc m'aider à régler ce problème.
Je vous remercie d'avance pour votre aide.
Cordialement,
Je vais essayer d'être le plus claire si cela ne l’était pas, veuillez m'en excusez d'avance.
Voilà la macro que j'ai créé :
Sub Macro2()
'
'Macro2 Macro()
'
'
Sheets("Fichier AC43").Select
Cells.Select
If Not Worksheets("Fichier AC43").AutoFilterMode Then
ActiveWorkbook.Worksheets("Fichier AC43").Range("A1:CK30000").AutoFilter
End If
For Each Ligne In Worksheets("Fichier AC43").Range("2:65535").Rows
If Ligne.Cells(1, 42).Value = "43" Then
ActiveWorkbook.Worksheets("Fichier AC43").AutoFilter.Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Fichier AC43").AutoFilter.Sort.SortFields.Add( _
Range("P1"), xlSortOnFontColor, xlAscending, , xlSortNormal).SortOnValue.Color _
= RGB(255, 0, 0)
With ActiveWorkbook.Worksheets("Fichier AC43").AutoFilter.Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
RowFin = Range("AX2").End(xlDown).Row
Range(Range("AN2"), Range("AX" & RowFin)).Select
Selection.Copy
Range("N2").Select
ActiveSheet.Paste
End If
Next
For Each Ligne In Worksheets("Fichier AC43").Range("2:65535").Rows
If Ligne.Cells(1, 68).Value = "43" Then
ActiveWorkbook.Worksheets("Fichier AC43").AutoFilter.Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Fichier AC43").AutoFilter.Sort.SortFields.Add( _
Range("P1"), xlSortOnFontColor, xlAscending, , xlSortNormal).SortOnValue.Color _
= RGB(0, 176, 240)
With ActiveWorkbook.Worksheets("Fichier AC43").AutoFilter.Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End If
If Ligne.Font.Color = RGB(0, 176, 240) Then
RowFin = Range("BX2").End(xlDown).Row
Range(Range("BN2"), Range("BX" & RowFin)).Select
Selection.Copy
Range("N2").Select
ActiveSheet.Paste
End If
Next
Cells.Select
With Selection.Font
.ColorIndex = xlAutomatic
.TintAndShade = 0
End With
End Sub
Le problème survient lors de la ligne If Ligne.Font.Color = RGB(0, 176, 240) et de la condition dessous car à ce moment la macro ne fait rien, il n'effectue pas le copier coller alors que la condition est remplie. Et si je retire cette condition, la macro me copie les cellules BN à BX qui ne correspondent pas à des lignes de couleur de police bleue et donc ma mise en forme n'est pas bonne.
Pourriez vous donc m'aider à régler ce problème.
Je vous remercie d'avance pour votre aide.
Cordialement,