|
|
|
|
Bonjour, j'ais généré via l'enregistreur de macro le code suivant devant me permettre de trier de manière croissante une suite de chiffres dans une colonne, mais j'ais une erreur 1004 qui apparait:
Sub TrierFourniture()
Range("B1:C8000").Select
Selection.Sort Key1:=Range("B1"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
End Sub
Bonjour,
Sub TrierFourniture()
With Sheets("Feuil1")
.Range("B1:C8000").Select
Selection.Sort Key1:=Range("B1"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
End With
End Sub
'
'
ou
Sub TrierFourniture(ByVal NomFeuille As String)
With Sheets(NomFeuille)
.Range("B1:C8000").Select
Selection.Sort Key1:=Range("B1"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
End With
End Sub
'
en espérant que j'ai vu juste, mais soyez conscient que je puis me tromper, je ne vois pas votre classeur !!! Lupin ~L'essentiel est invisible pour les yeux~ ~On ne voit bien qu'avec le coeur~ |
Re:
With Sheets("Feuil1")
.Range("B1:C8000").Select
Selection.Sort Key1:=Range("B1"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
End With
Le paramètre [ Header:=xlGuess ] est bien affecté par rapport à un tri contenant une entête [ Header:=xlYes ]. Lupin ~L'essentiel est invisible pour les yeux~ ~On ne voit bien qu'avec le coeur~ |
Sub TrierFourniture()
With Sheets("Fournitures")
Range("A1:F8000").Select
Selection.Sort Key1:=Range("A1"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
End With
End Sub
J'ais rajouté le dataoption, et l'erreur 1004 a refait son apparition ^^' |
Re:
Sub TrierFourniture()
With Sheets("Fournitures")
Range("A1:F8000").Select
Selection.Sort Key1:=Range("A1"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
End With
End Sub
Avec l'utilisation du mot clé [ With ], le mot clé [ Range ] doit être précédé d'un point [ . ]
Sub TrierFourniture()
With Sheets("Fournitures")
.Range("A1:F8000").Select
Selection.Sort Key1:=Range("A1"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
End With
End Sub
Lupin ~L'essentiel est invisible pour les yeux~ ~On ne voit bien qu'avec le coeur~ |
Re:
Option Explicit
Sub TrierFourniture()
With Sheets("Feuil1")
.Range("B1:C8000").Select
Selection.Sort Key1:=Range("B1"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
End With
End Sub
'
Toutefois, la même remarque peut s'appliquer sur la paramètre [ Key1 ]
Option Explicit
Sub TrierFourniture()
With Sheets("Feuil1")
.Range("B1:C8000").Select
Selection.Sort Key1:=.Range("B1"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
End With
End Sub
'
Lupin ~L'essentiel est invisible pour les yeux~ ~On ne voit bien qu'avec le coeur~ |
Re:
|