# Why is Writing to cells using for loop very slow [closed]

Sorry about the formatting, I don't know what went wrong. Using LO 5.4 I have a couple of identical for loops, one in Excel and the other in Calc that do the same thing. This loop in Calc takes about 10 times longer to run than the same loop in Excel. Both Loops are posted below. I suspect that the way I am writing to each cell in Calc may be inefficient - this line:

```
ThisComponent.Sheets(0).getCellByPosition(i,j).String = k
```

Is there a more efficient method of writing to each cell in Calc Basic or do macros in calc run slower than similar macros in Excel by nature ? I am looking at doing all of my spreadsheet consulting with Calc instead of Excel if possible. Just doing some comparisons at this point.

In Calc:

```
for i = 0 to 3 step 1
for j = 0 to 1500 step 1
k = j + sqr(j)
ThisComponent.Sheets(0).getCellByPosition(i,j).String = k
next j
next i
```

In Excel:

```
For c = 1 To 4 Step 1
For r = 1 To 1500 Step 1
k = j + sqrt(j)
Sheet2.Cells(r, c) = k
Next r
Next c
```