Bonjour,


J'aimerais si possible que l'on m'aide à optimiser mon code. Il marche mais j'aimerais augmenter sa vitesse d'éxécution et je ne vois pas comment faire. (Cela m'intéresserais beaucoup de connaître la meilleure méthode pour effectuer une recherche dans une feuille excel)

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
Sub TransformationDuCSV()
 
	ActiveSheet.Name = "PSPI"
 
	'[NE PAS MODIFIER]Suppression des 24 premières lignes du CSV
	Rows("1:24").Delete Shift:=xlUp
 
	'[NE PAS MODIFIER]Conversion du format CSV en EXCEL avec les cellules en textes
	Columns("A:A").TextToColumns Destination:=Range("A1"), DataType:=xlDelimited, _
        TextQualifier:=xlNone, ConsecutiveDelimiter:=False, Tab:=False, _
        Semicolon:=False, Comma:=False, Space:=False, Other:=True, OtherChar _
        :="=", FieldInfo:=Array(Array(1, 2), Array(2, 2)), TrailingMinusNumbers:=True
 
	'[NE PAS MODIFIER]Suppression de tous les espaces dans les cellules.
	Dim L, C
        For L = 1 To ActiveCell.SpecialCells(xlCellTypeLastCell).Row
        	For C = 1 To ActiveCell.SpecialCells(xlCellTypeLastCell).Column
			Cells(L, C).Value = Trim(Cells(L, C).Value)
        	Next
        Next
 
	Dim j As Long
	For j = 65536 To 1 Step -1
		If Cells(j, 1) = "Operator ID" Then Rows(j + 1).Delete Shift:=xlUp
                If Cells(j, 1) = "Enable status" Or Cells(j, 1) = "Re-enable date" Or Cells(j, 1) = "Approval status" Or Cells(j, 1) = "Last changed" Or Cells(j, 1) = "Last sign-on" Or Cells(j, 1) = "Calculated pwd" Or Cells(j, 1) = "One-time password" Or Cells(j, 1) = "Active devices" Then Rows(j).Delete Shift:=xlUp
	Next j
 
	'On commence du bas
	Dim i As Long
	For i = Selection.Rows.Count To 1 Step -1
		If WorksheetFunction.CountA(Selection.Rows(i)) = 0 Then	Selection.Rows(i).EntireRow.Delete
	Next i
 
	With Application
		.Calculation = xlCalculationAutomatic
		.ScreenUpdating = False
	End With
 
	'[NE PAS MODIFIER]Ligner les colonnes
	Application.ScreenUpdating = False
	Rows("1:1").Insert Shift:=xlDown
 
	With Sheets("PSPI").Range("A1:A" & [A65000].End(xlUp).Row)
		Set C = .Find("Operator ID", LookIn:=xlValues, LookAt:=xlWhole)
 
		If Not C Is Nothing Then
        		Firstaddress = C.Address
			Do
				derlig = Cells(C.Row, 1).Offset(0, 1).End(xlDown).Row
	                	derlig2 = [D65000].End(xlUp).Row + 2
		                Range(Cells(C.Row, 1), Cells(derlig, 2)).Copy
        		        Cells(derlig2, 4).PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _
		                    True, Transpose:=True
        		        Set C = .FindNext(C)
			Loop While Not C Is Nothing And C.Address <> Firstaddress
	        End If
	End With
 
	Columns("A:C").Delete Shift:=xlToLeft
	Rows("1:1").Delete Shift:=xlUp
	[A1].Select
 
        For j = 1 To 65536
                If Cells(j, 1) = "Operator ID" Then Rows(j - 1).Delete Shift:=xlUp
        Next j
 
        For j = 1 To 65536
        	If Cells(j, 1) = "Operator ID" Then Rows(j).Delete Shift:=xlUp
        Next j
 
End Sub
Merci pour votre aide future : o)
Je reste à votre disposition pour toute précision


Alphons