Probleme de macro
mikadu54
Messages postés
6
Date d'inscription
Statut
Membre
Dernière intervention
-
Patrice33740 Messages postés 8561 Date d'inscription Statut Membre Dernière intervention -
Patrice33740 Messages postés 8561 Date d'inscription Statut Membre Dernière intervention -
J'ai un problème sur une macro.
le begue est en gras
je n'arrive pas à mettre mon doc excel en ligne.
voici la macro:
Sub Ligue_2()
'
' Ligue_2 Macro
'
'
Range("G10:AJ29").Select
ActiveWorkbook.Worksheets("Classement").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Classement").Sort.SortFields.Add Key:= _
Range("G10:G29"), SortOn:=xlSortOnValues, Order:=xlDescending, DataOption _
:=xlSortNormal
ActiveWorkbook.Worksheets("Classement").Sort.SortFields.Add Key:= _
Range("P10:P29"), SortOn:=xlSortOnValues, Order:=xlDescending, DataOption _
:=xlSortNormal
ActiveWorkbook.Worksheets("Classement").Sort.SortFields.Add Key:= _
Range("N10:N29"), SortOn:=xlSortOnValues, Order:=xlDescending, DataOption _
:=xlSortNormal
ActiveWorkbook.Worksheets("Classement").Sort.SortFields.Add Key:= _
Range("H10:H29"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption _
:=xlSortNormal
With ActiveWorkbook.Worksheets("Classement").Sort
.SetRange Range("G10:AJ29")
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Range("F4:AJ4,I8:P8,R8:Y8,AA8:AH8").Select
Range("AA8").Activate
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Selection.Merge
Selection.Font.Bold = True
Range("F4:AJ4").Select
Selection.Font.Underline = xlUnderlineStyleSingle
ActiveCell.FormulaR1C1 = "=RC[-5]"
Range("I8:P8").Select
ActiveCell.FormulaR1C1 = "GÉNÉRAL"
Range("Q8").Select
ActiveCell.FormulaR1C1 = ""
Range("R8:Y8").Select
ActiveCell.FormulaR1C1 = "DOMICILE"
Range("AA8:AH8").Select
ActiveCell.FormulaR1C1 = "EXTÉRIEUR"
Range("H9").Select
ActiveCell.FormulaR1C1 = "ÉQUIPE"
Range("I9").Select
ActiveCell.FormulaR1C1 = "PNTS"
Range("J9").Select
ActiveCell.FormulaR1C1 = "J"
Range("K9").Select
ActiveCell.FormulaR1C1 = "G"
Range("L9").Select
ActiveCell.FormulaR1C1 = "N"
Range("M9").Select
ActiveCell.FormulaR1C1 = "P"
Range("N9").Select
ActiveCell.FormulaR1C1 = "BP"
Range("O9").Select
ActiveCell.FormulaR1C1 = "BC"
Range("P9").Select
ActiveCell.FormulaR1C1 = "DIFF"
Range("I9:Q9").Select
Selection.AutoFill Destination:=Range("I9:AH9"), Type:=xlFillDefault
Range("I9:AH9").Select
Range("F10").Select
ActiveCell.FormulaR1C1 = "1"
Range("F11").Select
ActiveCell.FormulaR1C1 = "2"
Range("F12").Select
ActiveCell.FormulaR1C1 = "3"
Range("F10:F12").Select
Selection.AutoFill Destination:=Range("F10:F29"), Type:=xlFillDefault
Range("F10:F29").Select
Range("F10:G29,I10:AJ29,H9:AH9").Select
Range("H9").Activate
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Range("F10:G29,I10:AJ29,H9:AH9,H10:H29,I8:AH8").Select
Range("I8").Activate
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
Range("F10:AJ11").Select
Application.CutCopyMode = False
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 10092543
.TintAndShade = 0
.PatternTintAndShade = 0
End With
Range("F12:AJ12").Select
With Selection.Interior
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorAccent6
.TintAndShade = 0.599993896298105
.PatternTintAndShade = 0
End With
Range("F27:AJ27").Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 16777062
.TintAndShade = 0
.PatternTintAndShade = 0
End With
Range("F28:AJ29").Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorAccent5
.TintAndShade = 0.599993896298105
.PatternTintAndShade = 0
End With
Range("F14:AJ14,F16:AJ16,F18:AJ18,F20:AJ20,F22:AJ22,F24:AJ24,F26:AJ26").Select
Range("AJ26").Activate
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorDark1
.TintAndShade = -4.99893185216834E-02
.PatternTintAndShade = 0
End With
Range("Q8:Q29,Z8:Z29,AI10:AI29").Select
Range("AI10").Activate
With Selection.Interior
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorLight1
.TintAndShade = 0
.PatternTintAndShade = 0
End With
Range("G6").Select
Dim equipe1 As Variant
Dim equipe2 As Variant
Dim place1 As Integer
Dim place2 As Integer
Dim numligne1 As Integer
Dim numligne2 As Integer
Dim classement As Integer
'numligne1 = 10
numligne2 = 49
For numligne1 = 10 To 29
equipe1 = Cells(numligne1, 8).Value
Do
equipe2 = Cells(numligne2, 8).Value
If equipe1 <> equipe2 Then
numligne2 = numligne2 + 1
End If
Loop Until equipe1 = equipe2
place1 = Cells(numligne1, 6).Value
place2 = Cells(numligne2, 6).Value
classement = place2 - place1
Cells(numligne1, 7).Value = classement
If classement > 0 Then
Range(Cells(numligne1, 6), Cells(numligne1, 36)).Select
Selection.Font.Color = -16776961
Selection.Font.Bold = True
End If
If classement < 0 Then
Range(Cells(numligne1, 6), Cells(numligne1, 36)).Select
Selection.Font.Color = -4165632
End If
numligne2 = 49
Next numligne1
End Sub
Merci de votre aide
le begue est en gras
je n'arrive pas à mettre mon doc excel en ligne.
voici la macro:
Sub Ligue_2()
'
' Ligue_2 Macro
'
'
Range("G10:AJ29").Select
ActiveWorkbook.Worksheets("Classement").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Classement").Sort.SortFields.Add Key:= _
Range("G10:G29"), SortOn:=xlSortOnValues, Order:=xlDescending, DataOption _
:=xlSortNormal
ActiveWorkbook.Worksheets("Classement").Sort.SortFields.Add Key:= _
Range("P10:P29"), SortOn:=xlSortOnValues, Order:=xlDescending, DataOption _
:=xlSortNormal
ActiveWorkbook.Worksheets("Classement").Sort.SortFields.Add Key:= _
Range("N10:N29"), SortOn:=xlSortOnValues, Order:=xlDescending, DataOption _
:=xlSortNormal
ActiveWorkbook.Worksheets("Classement").Sort.SortFields.Add Key:= _
Range("H10:H29"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption _
:=xlSortNormal
With ActiveWorkbook.Worksheets("Classement").Sort
.SetRange Range("G10:AJ29")
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Range("F4:AJ4,I8:P8,R8:Y8,AA8:AH8").Select
Range("AA8").Activate
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Selection.Merge
Selection.Font.Bold = True
Range("F4:AJ4").Select
Selection.Font.Underline = xlUnderlineStyleSingle
ActiveCell.FormulaR1C1 = "=RC[-5]"
Range("I8:P8").Select
ActiveCell.FormulaR1C1 = "GÉNÉRAL"
Range("Q8").Select
ActiveCell.FormulaR1C1 = ""
Range("R8:Y8").Select
ActiveCell.FormulaR1C1 = "DOMICILE"
Range("AA8:AH8").Select
ActiveCell.FormulaR1C1 = "EXTÉRIEUR"
Range("H9").Select
ActiveCell.FormulaR1C1 = "ÉQUIPE"
Range("I9").Select
ActiveCell.FormulaR1C1 = "PNTS"
Range("J9").Select
ActiveCell.FormulaR1C1 = "J"
Range("K9").Select
ActiveCell.FormulaR1C1 = "G"
Range("L9").Select
ActiveCell.FormulaR1C1 = "N"
Range("M9").Select
ActiveCell.FormulaR1C1 = "P"
Range("N9").Select
ActiveCell.FormulaR1C1 = "BP"
Range("O9").Select
ActiveCell.FormulaR1C1 = "BC"
Range("P9").Select
ActiveCell.FormulaR1C1 = "DIFF"
Range("I9:Q9").Select
Selection.AutoFill Destination:=Range("I9:AH9"), Type:=xlFillDefault
Range("I9:AH9").Select
Range("F10").Select
ActiveCell.FormulaR1C1 = "1"
Range("F11").Select
ActiveCell.FormulaR1C1 = "2"
Range("F12").Select
ActiveCell.FormulaR1C1 = "3"
Range("F10:F12").Select
Selection.AutoFill Destination:=Range("F10:F29"), Type:=xlFillDefault
Range("F10:F29").Select
Range("F10:G29,I10:AJ29,H9:AH9").Select
Range("H9").Activate
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Range("F10:G29,I10:AJ29,H9:AH9,H10:H29,I8:AH8").Select
Range("I8").Activate
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
Range("F10:AJ11").Select
Application.CutCopyMode = False
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 10092543
.TintAndShade = 0
.PatternTintAndShade = 0
End With
Range("F12:AJ12").Select
With Selection.Interior
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorAccent6
.TintAndShade = 0.599993896298105
.PatternTintAndShade = 0
End With
Range("F27:AJ27").Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 16777062
.TintAndShade = 0
.PatternTintAndShade = 0
End With
Range("F28:AJ29").Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorAccent5
.TintAndShade = 0.599993896298105
.PatternTintAndShade = 0
End With
Range("F14:AJ14,F16:AJ16,F18:AJ18,F20:AJ20,F22:AJ22,F24:AJ24,F26:AJ26").Select
Range("AJ26").Activate
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorDark1
.TintAndShade = -4.99893185216834E-02
.PatternTintAndShade = 0
End With
Range("Q8:Q29,Z8:Z29,AI10:AI29").Select
Range("AI10").Activate
With Selection.Interior
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorLight1
.TintAndShade = 0
.PatternTintAndShade = 0
End With
Range("G6").Select
Dim equipe1 As Variant
Dim equipe2 As Variant
Dim place1 As Integer
Dim place2 As Integer
Dim numligne1 As Integer
Dim numligne2 As Integer
Dim classement As Integer
'numligne1 = 10
numligne2 = 49
For numligne1 = 10 To 29
equipe1 = Cells(numligne1, 8).Value
Do
equipe2 = Cells(numligne2, 8).Value
If equipe1 <> equipe2 Then
numligne2 = numligne2 + 1
End If
Loop Until equipe1 = equipe2
place1 = Cells(numligne1, 6).Value
place2 = Cells(numligne2, 6).Value
classement = place2 - place1
Cells(numligne1, 7).Value = classement
If classement > 0 Then
Range(Cells(numligne1, 6), Cells(numligne1, 36)).Select
Selection.Font.Color = -16776961
Selection.Font.Bold = True
End If
If classement < 0 Then
Range(Cells(numligne1, 6), Cells(numligne1, 36)).Select
Selection.Font.Color = -4165632
End If
numligne2 = 49
Next numligne1
End Sub
Merci de votre aide
A voir également:
- Probleme de macro
- Telecharger macro convertir chiffre en lettre excel - Télécharger - Tableur
- Jitbit macro recorder - Télécharger - Confidentialité
- Télécharger macro convertir chiffre en lettre excel - Télécharger - Tableur
- Macro maker - Télécharger - Divers Utilitaires
- Macro word - Guide
1 réponse
Bonjour,
Ici un excellent cours VBA :
ftp://ftp-developpez.com/bidou/Cours/VBA/formationVBA.pdf
et ici une multitude d'exemples :
http://boisgontierjacques.free.fr/index2.htm
Ici un excellent cours VBA :
ftp://ftp-developpez.com/bidou/Cours/VBA/formationVBA.pdf
et ici une multitude d'exemples :
http://boisgontierjacques.free.fr/index2.htm