C
Cacou78
Guest
Bonjour, j'ai ce code suivant,et j'obtiens une erreur de type 1004 au niveau de ce que j'ai surligné en rouge.
J'ai sorti ce code de l'enregistreur de macros que j'ai modifié, a la base à ce niveau il y avait " array(4,5,6)".
Mais en fet j'ai besoin d'avoir un code générale, car mon tableau peut avoir 4 colonne comme 21. Sauriez vous comment faire?
En vous remerçiant, d'avance.
Rébecca
Sub tableau()
Dim DerLigne As Long
Dim DerColonne As Integer, I As Integer
Application.ScreenUpdating = False
With Sheets("Synt_charge")
DerLigne = .[A65000].End(xlUp).Row 'dernière ligne de la feuille Synt_charge
DerColonne = .[IV2].End(xlToLeft).Column 'dernière colonne de la ligne 2 de la feuille Synt_charge
End With
Sheets("Synt_charge").Activate
ActiveWindow.SmallScroll Down:=-14
Range(Cells(1, 1), Cells(DerLigne, DerColonne)).Sort Key1:=Range("A2"), Order1:=xlAscending, Key2:=Range( _
"B2"), Order2:=xlAscending, Header:=xlGuess, OrderCustom:=1, MatchCase _ 'tri les colonnes a et b
:=False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal, _
DataOption2:=xlSortNormal
Selection.Subtotal GroupBy:=1, Function:=xlSum, TotalList:=Range(Cells(1, 4), Cells(1, DerColonne)), _
Replace:=False, PageBreaks:=False, SummaryBelowData:=True ' sous total en fonction de colonne a, des colonnes 4 jusqu'à la derniere
Selection.Subtotal GroupBy:=2, Function:=xlSum, TotalList:=Range(Cells(1, 4), Cells(1, DerColonne)), _
Replace:=False, PageBreaks:=False, SummaryBelowData:=True ' sous total en fonction de colonne b, des colonnes 4 jusqu'à la derniere
ActiveSheet.Outline.ShowLevels RowLevels:=3
End Sub
J'ai sorti ce code de l'enregistreur de macros que j'ai modifié, a la base à ce niveau il y avait " array(4,5,6)".
Mais en fet j'ai besoin d'avoir un code générale, car mon tableau peut avoir 4 colonne comme 21. Sauriez vous comment faire?
En vous remerçiant, d'avance.
Rébecca
Sub tableau()
Dim DerLigne As Long
Dim DerColonne As Integer, I As Integer
Application.ScreenUpdating = False
With Sheets("Synt_charge")
DerLigne = .[A65000].End(xlUp).Row 'dernière ligne de la feuille Synt_charge
DerColonne = .[IV2].End(xlToLeft).Column 'dernière colonne de la ligne 2 de la feuille Synt_charge
End With
Sheets("Synt_charge").Activate
ActiveWindow.SmallScroll Down:=-14
Range(Cells(1, 1), Cells(DerLigne, DerColonne)).Sort Key1:=Range("A2"), Order1:=xlAscending, Key2:=Range( _
"B2"), Order2:=xlAscending, Header:=xlGuess, OrderCustom:=1, MatchCase _ 'tri les colonnes a et b
:=False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal, _
DataOption2:=xlSortNormal
Selection.Subtotal GroupBy:=1, Function:=xlSum, TotalList:=Range(Cells(1, 4), Cells(1, DerColonne)), _
Replace:=False, PageBreaks:=False, SummaryBelowData:=True ' sous total en fonction de colonne a, des colonnes 4 jusqu'à la derniere
Selection.Subtotal GroupBy:=2, Function:=xlSum, TotalList:=Range(Cells(1, 4), Cells(1, DerColonne)), _
Replace:=False, PageBreaks:=False, SummaryBelowData:=True ' sous total en fonction de colonne b, des colonnes 4 jusqu'à la derniere
ActiveSheet.Outline.ShowLevels RowLevels:=3
End Sub