If you are not a programmer, what are you trying to do with all that stupid code?
Calculate
d3 x j3 x 100
or,
if g3 is empty/null, just d3 x j3
Neither d3 nor j3 are formulas or empty.
That’s doing the reverse of your proposition. Instead of setting the formula via code, insert manually the formula (say @K3) you know that works, and see it via code.
You set the reference (the object) cell to K3 as you did, and get the formula string:
formula_string = oCell.getFormula()
or
select the cell (K3) and via the code you collect the formula:
formula_string = ThisComponent.CurrentSelection.getFormula()
…
MsgBox "the formula is " & formula_string