Please upload the full code of your soubroutine and an ODF type sample file here.
You can adjust the properties of the applied Cell Style by your macros. Always use Cell Styles instead of the direct formatting method.
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.