I have written a very straightforward script which writes data into excel cells. Basically, this is a loop over an array and it writes data into specific cells or formulas.
The problem is that this part of the script is extremly slow. Any ideas on how to improve thath?
Thanks.
For j = 0 To i - 1
'Insère nouvelle ligne
Rows(startRow & ":" & startRow).Select
Selection.Copy
Rows(startRow + 1 & ":" & startRow + 1).Select
Selection.Insert Shift:=xlDown
'Insère données
If roomType(j) <> "" Then
Feuil3.Cells(startRow, 1).Value = roomName(j)
Feuil3.Cells(startRow, 2).Value = roomSurface(j)
Feuil3.Cells(startRow, 7).Value = roomPeople(j)
Feuil3.Cells(startRow, 12).Value = roomPeople(j)
Feuil3.Cells(startRow, 5).Value = dict.Item(roomType(j))
Feuil3.Cells(startRow, 3).Value = roomHeight(j)
Feuil3.Range("F" & startRow).Formula = "=IFERROR(IF($E" & startRow & "=Data!$A$55,,ROUNDUP($B" & startRow & "/VLOOKUP($E" & startRow & ",Data!$A$3:$E$55,4,FALSE),0)),)"
Feuil3.Range("H" & startRow).Formula = "=$C$25"
Feuil3.Range("I" & startRow).Formula = "=IF($E" & startRow & "=Data!$A$55,$B" & startRow & "*$E$55,(MAX(F" & startRow & ",G" & startRow & ")*H" & startRow & "))"
Feuil3.Range("N" & startRow).Formula = "=IFERROR(VLOOKUP($K" & startRow & ",$M$22:$O$26,3,FALSE),)"
Feuil3.Range("O" & startRow).Formula = "=IFERROR(IF(ISBLANK(M" & startRow & ")=TRUE,L" & startRow & "*N" & startRow & ",L" & startRow & "*M" & startRow & "*N" & startRow & "),)"
Feuil3.Range("Q" & startRow).Formula = "=MAX(I" & startRow & ",O" & startRow & ")"
Feuil3.Range("T" & startRow).Formula = "=IFERROR(MAX(R" & startRow & ",S" & startRow & ")/(B" & startRow & "*C" & startRow & "),)"
End If
startRow = startRow + 1
Next j
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True