News:

BB code in posts seems to be working again!
I haven't turned on every single tag, so please let me know if there are any that are used/needed but not activated.

Main Menu

Manipulating a shape from another shape

Started by Crazy Squirrel, November 18, 2021, 08:57:40 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Crazy Squirrel

Ok, so I have two boxes.  Box 1 is red and box 2 is white. 
When I input the letter "Y" into box 1, I would like it to turn green. If I input the letter "N" into box 1, I would like it to turn white.
If box one has the letter "Y" and has turned green, I would then like box 2 to turn red until text is entered and it too will then turn green.
It is for a form to indicate further information is required in the adjacent box if Y is inputted.

Hope that makes sense!

vojo

within a shape:   Easy...for example
fillforegrnd = if(strsame(props.letter, "Y"),<green>, if(strsame(props.letter,"W",<Gray",)   ///last clause means do nothing

Between shapes:  Can be hard
- if shapes have fixed relationship (in a group, in a container, etc), can leverage above
- if shape dont have fixed relationship, then very difficult  to do....visio does not have shape discovery
   (one can no, without VBA, go find other shapes in the drawing via id or handle)

Crazy Squirrel

Thanks vojo.

Adding more than one IF statement is making my box either not change colour or change to black regardless of the colour I specify.

Combinations I've tried so far:-

=IF(STRSAME(Prop.letter,"Y"),3,1)=IF(STRSAME(Prop.letter,"N"),2,1)=IF(STRSAME(Prop.letter,""),2,1) - Stays white

=IF(STRSAME(SHAPETEXT(TheText),"N"),3,2)=IF(STRSAME(SHAPETEXT(TheText),"Y"),3,2) - White with no input, black with any text inserted

=IF(STRSAME(SHAPETEXT(TheText),"N"),2,3) - Red when "N" inputted but stays green at all other times.  Would like a third option.

Any help would be much appreciated.



Crazy Squirrel

UPDATE...

I've sorted the three colour problem

=IF(STRSAME(SHAPETEXT(TheText),"Y"),3,IF(STRSAME(SHAPETEXT(TheText),"N"),1,IF(STRSAME(SHAPETEXT(TheText),""),2,1)))

Now just need to link the boxes so if box 1 has a "Y" and tuns green, box 2 needs to turn red.

It's not going to happen is it!!

wapperdude

Here's reference on formula structure within the shapesheet:  https://docs.microsoft.com/en-us/previous-versions/office/developer/office-xp/aa200961(v=office.10)  This shows how to reference cells in another shape...which is what you want to do.

To use this, you need to know the identity of the box1 shape, i.e., sheet.X, where X is a number.  Assuming that box1 was the 1st shape on the page, it would be sheet.1.  So, your box2 formula would be.. IF(STRSAME(sheet.1!SHAPETEXT(TheText),"Y"),<red>,<gray>), where you must provide the red and gray definitions.



Visio 2019 Pro

Crazy Squirrel

Thanks wapperdude.

Unfortunately it keeps giving me an error from (TheText).

=IF(STRSAME(sheet.1060!SHAPETEXT(TheText),"Y"),2,3)

Any ideas?

Surrogate

#6
Quote from: Crazy Squirrel on November 19, 2021, 10:59:07 AM
Any ideas?
IF(STRSAME(SHAPETEXT(sheet.1060!TheText),"Y"),2,3)
Please read more about cell references !

vojo

use lots of user cells

user cell 1 = if(<check1>, true, false)
user cell 2 = if (check2>), true, user.cell1)
user cell 3 = if(<check3>),true,user.cell2)
...
user cell N = if(<check n>,true,user.celln-1)

etc

easier to debug

wapperdude

Oops.  Thanks Surrogate for catching the error.
Visio 2019 Pro

Crazy Squirrel

Thanks Surrogate.  I'd like to get a bit more technical!
Now that box 2 has turned red to indicate input is required, can I make it change to green once text has been entered?  Possilbly a then or else funcuntion?  (Still need the Y in box 1)

Surrogate

Quote from: Crazy Squirrel on November 30, 2021, 09:47:44 AMPossilbly a then or else funcuntion?  (Still need the Y in box 1)
You can use multiple nested IFs...

Crazy Squirrel

My first "IF" seams to be overwriting the others.  Could you have a look at it for me please?

=IF(STRSAME(SHAPETEXT(Sheet.1000!TheText),"y"),2,
IF(STRSAME(SHAPETEXT(Sheet.1000!TheText),"n"),1,
IF(STRSAME(SHAPETEXT(Sheet.1000!TheText),"Y"),2,
IF(STRSAME(SHAPETEXT(Sheet.1000!TheText),"N"),1,
IF(STRSAME(SHAPETEXT(Sheet.1000!TheText),"-"),1,
IF(STRSAME(SHAPETEXT(TheText),""),1,RGB(80,200,250)))))))

Surrogate

#12
Quote from: Surrogate on April 08, 2021, 08:33:37 PMI am sorry, i am Russian.
I may have misunderstood the task!

Crazy Squirrel

Awesome Surrogate, thank you.
I didn't need the drop down on shape data but managed to get it working with what was entered.  I'm sure you guys would have a more simpler way of doing this.

=IF(LEN(SHAPETEXT(TheText))>0,4),
IF(STRSAME(SHAPETEXT(Sheet.1000!TheText),"y"),2,
IF(STRSAME(SHAPETEXT(Sheet.1000!TheText),"n"),1,
IF(STRSAME(SHAPETEXT(Sheet.1000!TheText),"Y"),2,
IF(STRSAME(SHAPETEXT(Sheet.1000!TheText),"N"),1,
IF(STRSAME(SHAPETEXT(Sheet.1000!TheText),"-"),1,1))))))

wapperdude

For your scenario, the 1st IF would be the final result, and then work backwards in priority. Basically, reverse your order.

If there is a long concatenation, I would recommend using Visio's suggested method of putting each IF in a separate User entry.  It really helps for debugging and understanding, especially at a much later date.  Then, your construct becomes merely creating a conditional statement using the User row results.

Visio 2019 Pro

Browser ID: smf (possibly_robot)
Templates: 4: index (default), Display (default), GenericControls (default), GenericControls (default).
Sub templates: 6: init, html_above, body_above, main, body_below, html_below.
Language files: 4: index+Modifications.english (default), Post.english (default), Editor.english (default), Drafts.english (default).
Style sheets: 4: index.css, attachments.css, jquery.sceditor.css, responsive.css.
Hooks called: 420 (show)
Files included: 34 - 1306KB. (show)
Memory used: 1232KB.
Tokens: post-login.
Cache hits: 13: 0.00126s for 26,767 bytes (show)
Cache misses: 2: (show)
Queries used: 16.

[Show Queries]