Une instruction très longue
V
Bonjour les excellents,
voici mon code du moment:
Sub pdca()
Dim i, j, k As Integer
j = Sheets("PDCA").Range("A" & Rows.Count).End(xlUp).Row + 1
Application.ScreenUpdating = False
For i = 56 To 100
If Sheets("Daily").Range("L" & i) <> "" Then
For k = 3 To 26
Sheets("PDCA").Select
Cells(j, k - 2).Activate
With ActiveCell
.Value = Sheets("Daily").Cells(i, k)
.Borders.Weight = 2
.Borders.ColorIndex = 1
End With
Next
Range("J" & j & ":L" & j).Select
With Selection
.HorizontalAlignment = xlLeft
.MergeCells = True
End With
Range("M" & j & ":O" & j).Select
With Selection
.HorizontalAlignment = xlLeft
.MergeCells = True
End With
Range("P" & j & ":R" & j).Select
With Selection
.HorizontalAlignment = xlLeft
.MergeCells = True
End With
j = j + 1
End If
Next
Sheets("Daily").Select
Application.ScreenUpdating = True
MsgBox "Tout a bien été Dashé dans le PDCA"
End Subla ligne 11 met 6sec a s'éxécuter, pour quoi est-ce si long, comment puis resoudre ce problème?
Bonjour
la ligne 11 met 6sec a s'éxécuter, pour quoi est-ce si long, comment puis resoudre ce problème?
That's the question !
Votre code à essayer comme ceci
Sub pdca()
Dim i As Byte
Dim j As Integer, k As Integer
Application.ScreenUpdating = False
j = Sheets("PDCA").Range("A" & Rows.Count).End(xlUp).Row + 1
For i = 56 To 100
If Sheets("Daily").Range("L" & i) <> "" Then
With Sheets("PDCA")
For k = 3 To 26
With .Cells(j, k - 2)
.Value = Sheets("Daily").Cells(i, k)
.Borders.Weight = 2
.Borders.ColorIndex = 1
End With
Next k
With .Range("J" & j & ":L" & j)
.HorizontalAlignment = xlLeft
.MergeCells = True
End With
With Range("M" & j & ":O" & j)
.HorizontalAlignment = xlLeft
.MergeCells = True
End With
With Range("P" & j & ":R" & j)
.HorizontalAlignment = xlLeft
.MergeCells = True
End With
End With
j = j + 1
End If
Next i
Sheets("Daily").Select
Application.ScreenUpdating = True
MsgBox "Tout a bien été Dashé dans le PDCA"
End SubCordialement
V
finalement j'ai trouvé la solution:
j'ai ajouté une instruction: passer en recalcul manual au debut du script
Ok. Mais gardez le code proposé il devrait aller plus vite puisqu'on évite déjà tous les SELECT et ACTIVATE (à éviter à tout prix !!! avec VBA...sauf si vous voulez vraiment ralentir...
Si ok -->
Cordialement