Hello, I have a small problem. My code is running half of the time. When I press on my command button, my code works fine. When I repress on it to try something else, my code isnt running and I have an error 91. I press on end and retry my command button and it works fine. I dont know what is my error so, can someone help me?
Here's my code. It stops running at the first ActiveWorkbook line's. Thank you
Here's my code. It stops running at the first ActiveWorkbook line's. Thank you
Code:
Dim check As Long
Dim archdata As Long
Dim t As Long
Dim t2 As Long
Dim rouge As Integer
Dim jaune As Integer
Dim moc_nombre_rap As Integer
Dim moc_nombre_archive As Integer
Dim k As Integer
Dim flag As Boolean
Worksheets("Données brutes").Activate
Worksheets("Données brutes").Range("E2").Select
Selection.AutoFilter
ActiveWorkbook.Worksheets("Données brutes").AutoFilter.Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Données brutes").AutoFilter.Sort.SortFields.Add Key _
:=Range("E2:E213"), SortOn:=xlSortOnValues, Order:=xlAscending, _
DataOption:=xlSortNormal
ActiveWorkbook.Worksheets("Données brutes").AutoFilter.Sort.Header = xlYes
ActiveWorkbook.Worksheets("Données brutes").AutoFilter.Sort.MatchCase = False
ActiveWorkbook.Worksheets("Données brutes").AutoFilter.Sort.Orientation = xlTopToBottom
ActiveWorkbook.Worksheets("Données brutes").AutoFilter.Sort.SortMethod = xlPinYin
ActiveWorkbook.Worksheets("Données brutes").AutoFilter.Sort.Apply