Macro trop lente

Bonjour à tous,

Ma macro est trop lente !

Pouvez-vous faire en sorte de diminuer le temps d’exécution !

Sub Supprimer_Zero()

Dim i As Long, j As Long, derniere_ligne As Long

Application.ScreenUpdating = False

With Sheets(1)

derniere_ligne = Range("A1" ).End(xlDown).Row 'Dernière ligne de la base de données

For i = 1 To derniere_ligne

For j = 1 To 40

If .Cells(i, j) = 0 And .Cells(i, j).Interior.ColorIndex = xlNone Then .Cells(i, j) = ""

Next j

Next i

End With

Application.ScreenUpdating = True

End Sub

Merci & bonne soirée !

11essai-zero.zip (13.46 Ko)

Salut jbchb,

voici une solution mais une MFC judicieusement ajustée par un pro serait plus adéquate...

En attendant, ici, 100.000 lignes de 40 colonnes en 10'...

Dim tTab
Dim x, iRow As Long
Dim y As Integer
'
Application.ScreenUpdating = False
'
iRow = Range("A" & Rows.Count).End(xlUp).Row  'Dernière ligne de la base de données
iCol = Cells(1, Columns.Count).End(xlToLeft).Column
sCol = Split(Columns(iCol).Address(ColumnAbsolute:=False), ":")(1)
'
T = Timer
tTab = Range("A1:" & sCol & iRow)
'
'100.000 lig X 40 col
For x = 1 To iRow
    For y = 1 To iCol
        If tTab(x, y) = 0 Then
            If Cells(x, y).Interior.Color = RGB(255, 255, 255) Then tTab(x, y) = Null   '10 secondes
        End If
    Next
Next
Range("A1:" & sCol & iRow) = tTab
'
Application.ScreenUpdating = True
MsgBox Timer - T

A adapter!

A+

Re,

Merci beaucoup !

Bonne journée !

Rechercher des sujets similaires à "macro trop lente"