Optimiser un code VBA ?

Bonjour à tous, ci dessous 2 codes qui me permettent d'afficher/masquer des lignes en fonction de la valeur d'une premiere colonne puis une deuxième colonne. Elle fonctionne parfaitement, mais elle est longue (15min...). Bien que l'utilisation d'Excel via une tablette avec w10 soit en partie la cause du problème, ne serait-il pas possible d'optimiser ce code pour moins mouliner ?

Si quelqu'un à une solution, je suis preneur.

cordialement

Sub lancer_compilation()
'
Sheets("ATTENTE").Select

Application.DisplayStatusBar = True
Application.StatusBar = "Traitement en cours ..."
MsgBox "La compilation en cours prendra environ 5 minutes,et débutera aprés avoir cliquer sur OK, merci de patienter !"

'Sheets("PRESENTATION").Select
Sheets("ATTENTE").Select
Application.ScreenUpdating = False

Sheets("PRESENTATION").Select
Application.Run "compilation"

Application.ScreenUpdating = True
Sheets("PRESENTATION").Select

Application.DisplayStatusBar = False

End Sub
Sub compilation()

Rows("1:1000").Select
Selection.EntireRow.Hidden = False

Range("AC1:AC1000").Select
For Each Cell In Selection
Cpt = 0
For I = 0 To 0
If Cell.Offset(0, I) <> "0" Then
Cpt = Cpt + 1
End If
Next
If Cpt = 0 Then
Cell.EntireRow.Hidden = True
End If
Next

Range("AD1:AD1000").Select
For Each Cell In Selection
Cpt = 0
For j = 0 To 0
If Cell.Offset(0, j) <> "0" Then
Cpt = Cpt + 1
End If
Next
If Cpt = 0 Then
Cell.EntireRow.Hidden = True
End If
Next

Range("A1").Select

End Sub

bonsoir,

une proposition

Sub compilation()

Rows.Hidden = False

For Each cell In Range("AC1:AC1000")

If cell = 0 Then cell.EntireRow.Hidden = True

If cell.Offset(0, 1) = "0" Then cell.EntireRow.Hidden = True

Next

End Sub

Rechercher des sujets similaires à "optimiser code vba"