Bonjour,
y a t il un moyen d optimiser l insertion de ligne blanche sous Excel, et VBA ?
en fait je regarde un index et si celui ci change, j ajoute un ligne blanche
Start = Timer
' ajout d 'une ligne blanche entre chq vulnerabilité
ajout = 0
For Each c In Worksheets('feuille1').Range(Worksheets('feuille1').Cells(3, 1), _
Worksheets('feuille1').Cells(nb_ligne_total, 1))
If Worksheets('feuille1').Cells(c.Row, 1).Value <> _
Worksheets('feuille1').Cells(c.Row + 1, 1).Value And ajout = 0 Then
Worksheets('feuille1').Cells(c.Row + 1, 1).EntireRow.Insert
Worksheets('feuille1').Cells(c.Row + 1, 1).EntireRow.Interior.ColorIndex = 0
Worksheets('feuille1').Cells(c.Row + 1, 1).EntireRow.Borders.LineStyle = 0
ajout = 1
Else
ajout = 0
End If
Next
finish = Timer
tps_ajout = finish - Start
c est un tableau de 70 entrees environ et une 15aine d ajouts de lignes (c est un tableau dynamique donc assez variable)
le tps est d environ 2 secondes
ce qui est un peu long je trouve .
Merci de vos reponses
Romuald
y a t il un moyen d optimiser l insertion de ligne blanche sous Excel, et VBA ?
en fait je regarde un index et si celui ci change, j ajoute un ligne blanche
Start = Timer
' ajout d 'une ligne blanche entre chq vulnerabilité
ajout = 0
For Each c In Worksheets('feuille1').Range(Worksheets('feuille1').Cells(3, 1), _
Worksheets('feuille1').Cells(nb_ligne_total, 1))
If Worksheets('feuille1').Cells(c.Row, 1).Value <> _
Worksheets('feuille1').Cells(c.Row + 1, 1).Value And ajout = 0 Then
Worksheets('feuille1').Cells(c.Row + 1, 1).EntireRow.Insert
Worksheets('feuille1').Cells(c.Row + 1, 1).EntireRow.Interior.ColorIndex = 0
Worksheets('feuille1').Cells(c.Row + 1, 1).EntireRow.Borders.LineStyle = 0
ajout = 1
Else
ajout = 0
End If
Next
finish = Timer
tps_ajout = finish - Start
c est un tableau de 70 entrees environ et une 15aine d ajouts de lignes (c est un tableau dynamique donc assez variable)
le tps est d environ 2 secondes
ce qui est un peu long je trouve .
Merci de vos reponses
Romuald