petit souci sur macro excel 2007

eastwick

XLDnaute Impliqué
Bonsoir,

J'ai créé une macro (assez lourde) en enregistrement direct et voici le résultat : macro.jpg
La ligne 2 ne devrait pas s'y trouver... Quelle correction apporter pour la faire disparaître ?
Sub Macro3()
'
' Macro3 Macro
'

'
Columns("A:A").Select
Selection.Delete Shift:=xlToLeft
Columns("A:BS").Select
With Selection.Font
.Name = "Calibri"
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.TintAndShade = 0
.ThemeFont = xlThemeFontMinor
End With
With Selection.Font
.Name = "Calibri"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.TintAndShade = 0
.ThemeFont = xlThemeFontMinor
End With
With Selection.Font
.ThemeColor = xlThemeColorLight1
.TintAndShade = 0
End With
With Selection.Interior
.Pattern = xlNone
.TintAndShade = 0
.PatternTintAndShade = 0
End With
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
Selection.Borders(xlEdgeLeft).LineStyle = xlNone
Selection.Borders(xlEdgeTop).LineStyle = xlNone
Selection.Borders(xlEdgeBottom).LineStyle = xlNone
Selection.Borders(xlEdgeRight).LineStyle = xlNone
Selection.Borders(xlInsideVertical).LineStyle = xlNone
Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
Cells.Select
Selection.NumberFormat = "General"
Columns("A:B").Select
Range("B1").Activate
Selection.Delete Shift:=xlToLeft
Columns("A:A").Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Range("A2").Select
ActiveCell.FormulaR1C1 = "=LEFT(RC[1],4)"
Range("A2").Select
Selection.AutoFill Destination:=Range("A2:A6000"), Type:=xlFillDefault
Range("A2:A6000").Select
Columns("A:A").Select
Range("A5989").Activate
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
ActiveSheet.Paste
Application.CutCopyMode = False
With Selection.Font
.Name = "Calibri"
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.TintAndShade = 0
.ThemeFont = xlThemeFontMinor
End With
With Selection.Font
.Name = "Calibri"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.TintAndShade = 0
.ThemeFont = xlThemeFontMinor
End With
ActiveWindow.ScrollRow = 5949
ActiveWindow.ScrollRow = 5777
ActiveWindow.ScrollRow = 5605
ActiveWindow.ScrollRow = 94
ActiveWindow.ScrollRow = 54
ActiveWindow.ScrollRow = 1
Range("A1").Select
ActiveCell.FormulaR1C1 = "Année"
Columns("B:B").Select
Selection.Delete Shift:=xlToLeft
Columns("C:C").Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Range("C2").Select
ActiveCell.FormulaR1C1 = _
"=IF(RC[-1]="""","""",IF(ISNA(VLOOKUP(RC[-1],perso3,2,FALSE)),0,VLOOKUP(RC[-1],perso3,2,FALSE)))"
Range("C2").Select
Selection.Copy
ActiveWindow.ScrollRow = 14
ActiveWindow.ScrollRow = 160
ActiveWindow.ScrollRow = 305
ActiveWindow.ScrollRow = 5853
ActiveWindow.ScrollRow = 5893
ActiveWindow.ScrollRow = 5932
ActiveWindow.ScrollRow = 5946
ActiveWindow.SmallScroll Down:=27
Range("C3:C6000").Select
Range("C6000").Activate
ActiveSheet.Paste
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveWindow.ScrollRow = 5907
ActiveWindow.ScrollRow = 5761
ActiveWindow.ScrollRow = 54
ActiveWindow.ScrollRow = 27
ActiveWindow.ScrollRow = 1
Columns("C:C").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
ActiveSheet.Paste
Application.CutCopyMode = False
Range("C1").Select
ActiveCell.FormulaR1C1 = "Catégorie"
Columns("B:B").Select
Selection.Delete Shift:=xlToLeft
ActiveWindow.SmallScroll ToRight:=5
Columns("I:I").Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Range("I2").Select
ActiveCell.FormulaR1C1 = "=CONCATENATE(""C"",RC[1])"
Range("I2").Select
Selection.Copy
ActiveWindow.ScrollRow = 41
ActiveWindow.ScrollRow = 133
ActiveWindow.ScrollRow = 199
ActiveWindow.ScrollRow = 5919
ActiveWindow.ScrollRow = 5946
ActiveWindow.ScrollRow = 5972
Range("I3:I6000").Select
Range("I6000").Activate
ActiveSheet.Paste
ActiveSheet.Paste
Application.CutCopyMode = False
Columns("I:I").Select
Range("I5986").Activate
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveWindow.ScrollRow = 5973
ActiveWindow.ScrollRow = 5960
ActiveWindow.ScrollRow = 5854
ActiveWindow.ScrollRow = 27
ActiveWindow.ScrollRow = 1
Range("I1").Select
ActiveCell.FormulaR1C1 = "Statut"
Range("J2").Select
Selection.ClearContents
ActiveCell.FormulaR1C1 = _
"=IF(RC[-1]="""","""",IF(ISNA(VLOOKUP(RC[-1],perso2,2,FALSE)),0,VLOOKUP(RC[-1],perso2,2,FALSE)))"
Range("J2").Select
Selection.Copy
ActiveWindow.ScrollRow = 80
ActiveWindow.ScrollRow = 252
ActiveWindow.ScrollRow = 397
ActiveWindow.ScrollRow = 5946
ActiveWindow.ScrollRow = 5972
Range("J3:J6000").Select
Range("J6000").Activate
ActiveSheet.Paste
ActiveSheet.Paste
Application.CutCopyMode = False
Columns("J:J").Select
Range("J5986").Activate
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveWindow.ScrollRow = 5893
ActiveWindow.ScrollRow = 5562
ActiveWindow.ScrollRow = 41
ActiveWindow.ScrollRow = 1
Range("D2").Select
ActiveCell.FormulaR1C1 = "=CONCATENATE(RC[-2],""-"",RC[6])"
Range("D2").Select
Selection.Copy
ActiveWindow.ScrollRow = 80
ActiveWindow.ScrollRow = 239
ActiveWindow.ScrollRow = 5959
ActiveWindow.ScrollRow = 5972
Range("D3:D6000").Select
Range("D6000").Activate
ActiveSheet.Paste
ActiveSheet.Paste
Application.CutCopyMode = False
Columns("D:D").Select
Range("D5986").Activate
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveWindow.ScrollRow = 5973
ActiveWindow.ScrollRow = 5920
ActiveWindow.ScrollRow = 14
ActiveWindow.ScrollRow = 1
Range("D1").Select
ActiveCell.FormulaR1C1 = "Grade/Statut"
Columns("E:E").Select
Selection.Delete Shift:=xlToLeft
Selection.Delete Shift:=xlToLeft
ActiveWindow.SmallScroll ToRight:=2
Columns("E:H").Select
Selection.Delete Shift:=xlToLeft
Range("H2").Select
ActiveCell.FormulaR1C1 = "=(RC[-1]*1)"
Range("H2").Select
Selection.Copy
ActiveWindow.ScrollRow = 14
ActiveWindow.ScrollRow = 133
ActiveWindow.ScrollRow = 5549
ActiveWindow.ScrollRow = 5668
ActiveWindow.ScrollRow = 5774
ActiveWindow.ScrollRow = 5853
ActiveWindow.ScrollRow = 5906
ActiveWindow.ScrollRow = 5972
Range("H3:H6000").Select
Range("H6000").Activate
ActiveSheet.Paste
ActiveSheet.Paste
Application.CutCopyMode = False
Columns("H:H").Select
Range("H5986").Activate
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveWindow.ScrollRow = 5960
ActiveWindow.ScrollRow = 5840
ActiveWindow.ScrollRow = 41
ActiveWindow.ScrollRow = 14
ActiveWindow.ScrollRow = 1
Range("G2").Select
Selection.ClearContents
ActiveCell.FormulaR1C1 = _
"=IF(RC[1]="""","""",IF(ISNA(VLOOKUP(RC[1],serv,3,FALSE)),0,VLOOKUP(RC[1],serv,3,FALSE)))"
Range("G2").Select
Selection.Copy
ActiveWindow.ScrollRow = 14
ActiveWindow.ScrollRow = 160
ActiveWindow.ScrollRow = 5959
ActiveWindow.ScrollRow = 5972
Range("G3:G6000").Select
Range("G6000").Activate
ActiveSheet.Paste
ActiveSheet.Paste
Application.CutCopyMode = False
Columns("G:G").Select
Range("G5986").Activate
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveWindow.ScrollRow = 5960
ActiveWindow.ScrollRow = 5814
ActiveWindow.ScrollRow = 41
ActiveWindow.ScrollRow = 14
ActiveWindow.ScrollRow = 1
Range("G1").Select
ActiveCell.FormulaR1C1 = "Pole"
Range("G2").Select
ActiveWindow.ScrollColumn = 2
ActiveWindow.ScrollColumn = 1
Columns("B:C").Select
Selection.Delete Shift:=xlToLeft
Columns("F:F").Select
Selection.Delete Shift:=xlToLeft
Selection.Delete Shift:=xlToLeft
Range("F2").Select
ActiveCell.FormulaR1C1 = "=ROUND(RC[-3],4)"
Range("F2").Select
Selection.NumberFormat = "#,##0.0000"
Selection.AutoFill Destination:=Range("F2:G2"), Type:=xlFillDefault
Range("F2:G2").Select
Selection.Copy
ActiveWindow.ScrollRow = 107
ActiveWindow.ScrollRow = 292
ActiveWindow.ScrollRow = 5946
ActiveWindow.ScrollRow = 5959
ActiveWindow.ScrollRow = 5972
Range("F3:G6000").Select
Range("F6000").Activate
ActiveSheet.Paste
ActiveSheet.Paste
Application.CutCopyMode = False
Columns("F:G").Select
Range("F5986").Activate
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveWindow.ScrollRow = 5946
ActiveWindow.ScrollRow = 5827
ActiveWindow.ScrollRow = 54
ActiveWindow.ScrollRow = 41
ActiveWindow.ScrollRow = 1
Range("F1").Select
ActiveCell.FormulaR1C1 = "Physique"
Range("G1").Select
ActiveCell.FormulaR1C1 = "ETP"
Range("F1:G1").Select
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Selection.Font.Bold = True
Columns("C:D").Select
Selection.Delete Shift:=xlToLeft
ActiveWindow.SmallScroll Down:=147
ActiveWindow.ScrollRow = 146
ActiveWindow.ScrollRow = 133
ActiveWindow.ScrollRow = 120
ActiveWindow.ScrollRow = 67
ActiveWindow.ScrollRow = 1
Range("B9").Select
Selection.AutoFilter
ActiveSheet.Range("$A$1:$E$6000").AutoFilter Field:=1, Criteria1:="="
Rows("3664:6058").Select
Selection.Delete Shift:=xlUp
Range("B3670").Select
ActiveSheet.Range("$A$1:$E$3663").AutoFilter Field:=1
Range("C12").Select
Selection.AutoFilter
Columns("A:A").Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Range("A2").Select
ActiveCell.FormulaR1C1 = "=CONCATENATE(RC[2],RC[3],RC[1])"
Range("A2").Select
With Selection.Font
.Name = "Calibri"
.Size = 6
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = 1
.TintAndShade = 0
.ThemeFont = xlThemeFontMinor
End With
With Selection.Font
.Name = "Calibri"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = 1
.TintAndShade = 0
.ThemeFont = xlThemeFontMinor
End With
Columns("A:A").ColumnWidth = 12.14
Selection.Copy
ActiveWindow.ScrollRow = 54
ActiveWindow.ScrollRow = 120
ActiveWindow.ScrollRow = 3977
ActiveWindow.ScrollRow = 3990
Range("A3:A4000").Select
Range("A4000").Activate
ActiveSheet.Paste
ActiveSheet.Paste
Application.CutCopyMode = False
Columns("A:A").Select
Range("A3986").Activate
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveWindow.ScrollRow = 3990
ActiveWindow.ScrollRow = 27
ActiveWindow.ScrollRow = 1
Range("A1").Select
ActiveCell.FormulaR1C1 = "Info"
Rows("1:1").Select
With Selection.Font
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.TintAndShade = 0
End With
With Selection.Font
.Name = "Calibri"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.TintAndShade = 0
.ThemeFont = xlThemeFontMinor
End With
With Selection
.HorizontalAlignment = xlCenter
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Selection.Font.Bold = True
With Selection
.HorizontalAlignment = xlRight
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
With Selection
.HorizontalAlignment = xlRight
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
With Selection
.HorizontalAlignment = xlRight
.VerticalAlignment = xlCenter
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Columns("A:A").Select
Selection.ColumnWidth = 15
Columns("B:D").Select
Selection.Delete Shift:=xlToLeft
Range("A10").Select
Selection.AutoFilter
ActiveSheet.Range("$A$1:$C$4000").AutoFilter Field:=1, Criteria1:="="
Rows("3664:4223").Select
Selection.Delete Shift:=xlUp
ActiveSheet.Range("$A$1:$C$3663").AutoFilter Field:=1
Columns("A:C").Select
Selection.ColumnWidth = 15
Range("C8").Select
Selection.AutoFilter
ActiveWindow.ScrollRow = 54
ActiveWindow.ScrollRow = 186
ActiveWindow.ScrollRow = 3977
ActiveWindow.ScrollRow = 3990
Range("A1:C4000").Select
Range("C4000").Activate
With Selection.Interior
.PatternColorIndex = 2
.Color = 49407
.TintAndShade = 0
.PatternTintAndShade = 0
End With
ActiveWindow.ScrollRow = 3990
ActiveWindow.ScrollRow = 3977
ActiveWindow.ScrollRow = 27
ActiveWindow.ScrollRow = 14
ActiveWindow.ScrollRow = 1
Range("A1:C4000").Select
Range("A4000").Activate
ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
"personnel!R1C1:R4000C3", Version:=xlPivotTableVersion12). _
CreatePivotTable TableDestination:="personnel!R1C6", TableName:= _
"Tableau croisé dynamique2", DefaultVersion:=xlPivotTableVersion12
Sheets("personnel").Select
Cells(1, 6).Select
ActiveWorkbook.ShowPivotTableFieldList = True
With ActiveSheet.PivotTables("Tableau croisé dynamique2").PivotFields("Info")
.Orientation = xlRowField
.Position = 1
End With
ActiveSheet.PivotTables("Tableau croisé dynamique2").AddDataField ActiveSheet. _
PivotTables("Tableau croisé dynamique2").PivotFields("ETP"), "Nombre de ETP", _
xlCount
With ActiveSheet.PivotTables("Tableau croisé dynamique2").PivotFields( _
"Nombre de ETP")
.Caption = "Somme de ETP"
.Function = xlSum
End With
ActiveSheet.PivotTables("Tableau croisé dynamique2").AddDataField ActiveSheet. _
PivotTables("Tableau croisé dynamique2").PivotFields("Physique"), _
"Nombre de Physique", xlCount
With ActiveSheet.PivotTables("Tableau croisé dynamique2").PivotFields( _
"Nombre de Physique")
.Caption = "Somme de Physique"
.Function = xlSum
End With
ActiveWorkbook.ShowPivotTableFieldList = False
Columns("E:I").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
ActiveSheet.Paste
Application.CutCopyMode = False
Columns("A:E").Select
Range("E1").Activate
Selection.Delete Shift:=xlToLeft
Cells.Select
With Selection.Font
.Name = "Calibri"
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.TintAndShade = 0
.ThemeFont = xlThemeFontMinor
End With
With Selection.Font
.Name = "Calibri"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.TintAndShade = 0
.ThemeFont = xlThemeFontMinor
End With
With Selection.Font
.ThemeColor = xlThemeColorLight2
.TintAndShade = -0.249977111117893
End With
Columns("B:C").Select
Selection.NumberFormat = "#,##0.00"
Rows("1:1").Select
With Selection
.HorizontalAlignment = xlCenter
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Columns("A:C").Select
Selection.ColumnWidth = 20
Range("A1").Select
ActiveCell.FormulaR1C1 = "Information"
Range("B1").Select
ActiveCell.FormulaR1C1 = "ETP"
Range("C1").Select
ActiveCell.FormulaR1C1 = "Physique"
Rows("1:1").Select
With Selection.Font
.Name = "Calibri"
.Size = 11
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ThemeColor = xlThemeColorLight2
.TintAndShade = -0.249977111117893
.ThemeFont = xlThemeFontMinor
End With
Selection.Font.Bold = True
Selection.Font.Italic = True
Columns("D:I").Select
Selection.Delete Shift:=xlToLeft
ActiveWindow.ScrollRow = 54
ActiveWindow.ScrollRow = 160
ActiveWindow.ScrollRow = 3872
ActiveWindow.ScrollRow = 3885
ActiveWindow.SmallScroll Down:=87
Range("A1:C140").Select
Range("A140").Activate
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 15854261
.TintAndShade = 0
.PatternTintAndShade = 0
End With
ActiveWorkbook.Names.Add Name:="personnel", RefersToR1C1:= _
"='personnel'!R1C1:R140C3"
ActiveWindow.ScrollRow = 130
ActiveWindow.ScrollRow = 65
ActiveWindow.ScrollRow = 27
ActiveWindow.ScrollRow = 14
ActiveWindow.ScrollRow = 1
Range("A1").Select
End Sub


Je vous remercie.
 

Pièces jointes

  • macro.jpg
    macro.jpg
    39.5 KB · Affichages: 107
  • macro.jpg
    macro.jpg
    39.5 KB · Affichages: 110

Discussions similaires

Statistiques des forums

Discussions
312 219
Messages
2 086 372
Membres
103 198
dernier inscrit
CACCIATORE