In excel, we insert a shape, and we can link it to a cells value, by selecting shape and typing the cell reference in formula bar. I want to know: How can we do that programmatically. Like
For Each shape As Excel.Shape In workshet.Shapes
'is there something like shape.Formula or any method from which I can do the above
task.
Next
Here is what I want to do programmatically
It's been days now , I am searching it. Really Need help, Thanks Alot.
You don't need to use Select to apply formulas to Shapes. Select should be avoided wherever possible as it bloats code, and can have unintended consequences - for example triggering Events
Instead you can work with the Formula directly by using DrawingOBject, see
FormApp
which also will let you manipulate existing formula (ie add 6 cell to A2 to make it A8, A12 to A18 etc). The second code routineFormAdd
makes this adjustment, it works on both cell addresses and range namesThe simplest option is to programatically select the shape first, then apply the formula
Or course this will error if a shape on the sheet does not support the
.Formula
property