Pour valider des chiffres a la place des lettres code VBA

salut

quoi mettre pour modifier ce code qui marche avec des lettres dans la colonne mais pas avec des chiffres merci

Private Sub CommandButton5_Click()
''Tri (N° Bon) de la colonne A "suivant" la colonne E
ActiveWorkbook.Worksheets("Mémo").Sort.SortFields.Clear
    ActiveWorkbook.Worksheets("Mémo").Sort.SortFields.Add Key:=Range("e6"), _
        SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
    With ActiveWorkbook.Worksheets("Mémo").Sort
        .SetRange Range("a6:d50000")
        .Header = xlNo
        .MatchCase = False
        .Orientation = xlTopToBottom
        .SortMethod = xlPinYin
        .Apply
    End With
End Sub

Bonjour,

Key:= Cells(6, 5)
.SetRange .Range(.Cells(6, 1), .Cells(6, 50000))

il y mois de risque d'erreur comme ceci:

  LastRw = Cells(Rows.Count, 1).End(xlUp).Row
  Range(Cells(5, 1).Address, Cells(LastRw, 6).Address).Select

    With ActiveWorkbook.Worksheets(ActiveSheet.Name).Sort
        .SortFields.Clear
        .SortFields.Add Key:=Range(Cells(5, 5).Address), _
            SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
        .SetRange Range(Cells(5, 1).Address, Cells(LastRw, 6).Address)
        .Header = xlYes
        .MatchCase = False
        .Orientation = xlTopToBottom
        .SortMethod = xlPinYin
        .Apply
    End With

salut sabv

marche pas ou je me suis tromper

(propriete ou methode non geree par cet objet)

Private Sub CommandButton5_Click()
''Tri (N° Bon) de la colonne A "suivant" la colonne E
ActiveWorkbook.Worksheets("Mémo").Sort.SortFields.Clear
    ActiveWorkbook.Worksheets("Mémo").Sort.SortFields.Add Key:=Cells(6, 5), _
        SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
    With ActiveWorkbook.Worksheets("Mémo").Sort
        .SetRange .Range(.Cells(6, 1), .Cells(6, 50000))
        .Header = xlNo
        .MatchCase = False
        .Orientation = xlTopToBottom
        .SortMethod = xlPinYin
        .Apply
    End With
End Sub

merci sabV de m avoir aider l erreur est de moi g rajouter une colonne et pas modifier la ref de la colonne

le code bon code et celui la après avoir supprimer cette colonne

Sub Bouton1_N°deBons_Mémo_Clic()

''Tri (N° Bon) de la colonne A "suivant" la colonne E
 ActiveWorkbook.Worksheets("Mémo").Sort.SortFields.Clear
    ActiveWorkbook.Worksheets("Mémo").Sort.SortFields.Add Key:=Range("e6"), _
        SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
    With ActiveWorkbook.Worksheets("Mémo").Sort
        .SetRange Range("a6:I50000")
        .Header = xlNo
        .MatchCase = False
        .Orientation = xlTopToBottom
        .SortMethod = xlPinYin
        .Apply
    End With

End Sub
Rechercher des sujets similaires à "valider chiffres place lettres code vba"