How can I make this macro run in any worksheet. For now it runs only if the sheet name is "Sheet1 (2)"
I am a beginner and very happy to have created this macro. Now I would like it to work all the time
I am a beginner and very happy to have created this macro. Now I would like it to work all the time
VBA Code:
Sub TricolonneC()
'
' TricolonneC Macro
'
' Touche de raccourci du clavier: Ctrl+t
'
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToRight)).Select
ActiveWorkbook.Worksheets("Sheet1 (2)").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Sheet1 (2)").Sort.SortFields.Add2 Key:=ActiveCell. _
Offset(0, 1).Range("A1:A5"), SortOn:=xlSortOnValues, Order:=xlAscending, _
DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Sheet1 (2)").Sort
.SetRange ActiveCell.Range("A1:B5")
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End Sub
Last edited by a moderator: