Hey everybody,

I am trying to fill a Cell in Excel with a string that includes integer variables.
This is the code:

Dim Amountofpayments As Integer
Dim Count As Integer

Amountofpayments = Worksheets(1).Cells(14, 18)
Amountofpayments = Amountofpayments + 9
Count = 10
Do Until Count > Amountofpayments
    Worksheets(2).Cells(Count, 1) = Count - 9
    Worksheets(2).Cells(Count, 2) = "=IF(A" & Count & "=Main!$R$14;D" & Count & "*(Main!$R$17*(Main!$R$11/Main!$R$14)/100)+D" & Count & ";D" & Count & "*(Main!$R$17*(Main!$R$11/Main!$R$14)/100))"
    Worksheets(2).Cells(Count, 3) = "=IF(A" & Count - 1 & "=Main!$R$14;D" & Count - 1 & ";0)"


....


    Count = Count + 1
    

Loop
However, I get a runtime Error in every line, whenever I am trying to concatenate the variable in the string.

Does anybody see the mistake?

Thanks in advance, regards