Inserted by editing:
Sorry. I missed that this was your first post to the forum. Therefore:
First of all a welcome!
(My original post:)
First of all:
This is not a topic fitting under "General discussion". The appropriate branch is eother "Calc" or "Macros".
You should tell clearly what you want to achieve.
Most likely user code is not needed for it.
If at all user code shold be an appropriate means regarding your goals, you again should tell what you want instead of posting dysfunctional code. Analysing this kind of code just to be able to reversely find out what was intended is an annoying waste of time.
If you post code you should consider that spreading it sparse over a canvas will not make it understandable. Clearly structured, but compact, is better, and most relevant again: Comment on your code to make your intentions clear.
If you yourself don't feel sure about understanding the details sufficiently, never pack a lot of steps into one line of code. It aggravats design and understanding as well.
Look at this now. (It's
not "a solution".)
Code: Select all
Dim LI1, LF1, xh REM Types?
actRow = 20 + myParameter REM Does not depend on the control (Loop-) variable i.
LI1 = 21 REM If LI1 is functionally a constant, you should handle it this way.
LF1 = LI1 + myParameter - 1 REM Again independent of the control variable.
REM For the constant 21 you introduced a (non-speaking) name.
REM For the constants 23, 11, and 20 you didn't. Why?
For i = 1 To numLoops
xh_i = 23 + (11*(i-1))
REM First time i is used. I added the "_i" to the name to emphasise this. Creates
REM the sequence xh_i = 23, 34, 45, ... used for API column indices. Is this what you want?
myCell = oSheet.getCellByPosition(xh_i, actRow)
REM Assuming actRow is 55 you get the cells X55, AI55, AT55 ... Is this what you want?
REM You seem to try to do something every 11th column the same row. What sense in it?
myFormula_i =
REM "=SUM(M + ("xh")" & LI1 & ":M + ("xh")" & LF1 & ")" Doesn't tell me clearly what's intended.
REM ***** ==== YOU should tell me. ==== *****
myCell.setFormula(myFormula_i)
Next i
On Windows 10: LibreOffice 24.2 (new numbering) and older versions, PortableOpenOffice 4.1.7 and older, StarOffice 5.2
---
Lupp from München