Bonjour,
Dans le cadre d'une formation Excel, je suis actuellement sur les macros.
Je suis sous Excel 365 version anglophone et apparemment le professeur en podcast sous Excel 2013.
Voici le code initial du VBA :
Sub DivisionSort()
'
' Sort List by Division Ascending
'
'
Selection.Sort Key1:=Range("A4"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
End Sub
Sub CategorySort()
'
' Sort List by Category Ascending
'
'
Selection.Sort Key1:=Range("B4"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
End Sub
Sub TotalSort()
'
' Sort List by Total Sales Ascending
'
'
Selection.Sort Key1:=Range("F4"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
End Sub
Après rajout exact du code demandé par le professeur, voici ce qui apparait en pour générer la boite de choix de sélection :
Public Sub UserSortInput()
Dim UserInput As String
Dim promptMSG As String
promptMSG = "Enter a numeric value to sort..." & vbCrLf & _
"1 --- Sort by Division" & vbCrLf & _
"2 --- Sort by Category" & vbCrLf & _
"3 --- Sort by Total"
UserInput = InputBox(promptMSG)
If UserInput = "1" Then
DivisionSort
ElseIf UserInput = "2" Then
CategorySort
ElseIf UserInput = "3" Then
TotalSort
End If
À chaque fois j'ai des messages d'erreur différents, Break mode ou Error 1004.
Sauriez vous m'en dire plus ? Je tourne en rond depuis 1 semaine à cause de ce problème.
Merci d,avance pour votre aide et bonne journée
Louis