Modify by code a cell that has a BOUND formula

Started by Yacine, May 05, 2022, 07:50:01 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Yacine

Say you have a cell whose value is constrained by a BOUND formula and you want to overwrite its value - NOT the formula - by code.


Instead of shp.Cells(your_cell_name).Formula = ... ,
write shp.Cells(your_cell_name).ResultIU = ...


Interesting enough, if you write a value outside the allowed range, the value gets written into the value parameter of the BOUND formula, but the value of the cell itself is still correctly within the boundaries.
So if you want to know the limits of the cell, you could instead of parsing the formula, set its values to very high and very low values and read the according values.


PS: I haven't yet tried other assignments thant ResultIU.
Yacine

Yacine

#1
Yeah! I need to share this:
If you write a bound formula in a prop cell it won't get overwritten when you type in values and even better, the values are restrained as it should.
Great feature, I would have liked to know before.
Yacine

Visisthebest

Visio 2021 Professional

wapperdude

I can confirm the ResultIU() method.
I also get the same behavior with Formula.  Also, using SETATREF in Prop Data produces same behavior. 

My target cell in all cases was Width.
Obviously, FormulaForce clobbers the formula in the width cell and replaces it with the specified value.

Visio 2019 Pro

Yacine

SETATREF is certainly the better way to do it.
I just happen to struggle with all the SETATREF, SETATREFEXPR, ... functions.
Need to take the time to investigate on them, they are so useful.
Yacine

wapperdude

SETATREF is definitely challenging.  It takes hands-on to really get to feeling comfortable with that group of functions.  Don't know if you've looked at my post, "What's with SETATREF?" in the User Submitted Stuff, http://visguy.com/vgforum/index.php?topic=6383.msg26308#msg26308.  It might be helpful.  I had intended it to be kinda like a tutorial, so if of interest, start at the 1st post and progressively work thru it?  Hopefully it will shed some light on the topic.





Visio 2019 Pro