Re : Selectionner plage de cellules VBA
Désolé j'arrive pas à éditer donc plus d'infos :
Range("A1:AH" & Range("AH65536").End(xlUp).Row).Select 'Là il me trovue la dernière ligne et me sélectionne, ça c'est bon
ActiveWorkbook.Worksheets("Sort by Out of Stock Today").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Sort by Out of Stock Today").Sort.SortFields.Add _
Key:=Range("A1:AH" & Range("AH65536").End(xlUp).Row), SortOn:=xlSortOnValues, Order:=xlDescending, _
DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Sort by Out of Stock Today").Sort
.SetRange Range("A1:AH" & Range("AH65536").End(xlUp).Row)
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Il plante au .Apply, ma première ligne de code trouve bien la fin, mais pour le tri, j'ai l'impression qu'il "reselectionne". Merci.
Voici le code de base :
Range("A1:AH1276").Select
ActiveWorkbook.Worksheets("Sort by Out of Stock Today").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Sort by Out of Stock Today").Sort.SortFields.Add _
Key:=Range("O2:O1276"), SortOn:=xlSortOnValues, Order:=xlDescending, _
DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Sort by Out of Stock Today").Sort
.SetRange Range("A1:AH1276")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Voici le code que j'ai essayé de modifier en sorte qu'il trouve la fin tout seul... sans succès... Ce code fonctionne que si j'ai 1276 lignes...