Changing variable in a formula (Updating input of function)

Hi,

I have started to write a macro to create document easily.

It is going to finish but I found a mistake in my macro. When I update input of my function, it updates variable of my formula. But it gives error.

My Formula:

oCellYD.setFormula("=K" & iRowYD + 1 "*L" & iRowYD + 1 "*N" & iRowYD + 1 & "*M" & iRowYD + 1 & "/O" & iRowYD + 1)

It gives error. That is:

"BASIC syntax error.
Parentheses do not match."

I guess, it is about iRowYD variable. Every time, I call my function, iRowYD variable changes(increases).

Where should I change to fix this issue.

Sorry for my bad English.
Thanks for your time.

Is this about passing a parameter to a ‘Sub’ or about needing a loop to vary the iRowYD value or about … ???
Would you mind to explain for what reason you think you need this complicated construct? On the formula level your task might better be done by =PROD(OFFSET(K1;iStartYD;0;1;4)). Again we may have the need to pass iAtartYD. … See above.

I have created a sub routine and created a loop to call this subroutine but it fails. I says Parentheses do not match.

Where should I change to fix this issue

It seems to me you missed to add a & operator at two places. Try if this works:

oCellYD.setFormula("=K" & iRowYD + 1 & "*L" & iRowYD + 1 & "*N" & iRowYD + 1 & "*M" & iRowYD + 1 & "/O" & iRowYD + 1)