Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I'm trying to hide a sheet object unless a single selection is made in a specific field.
If I have 3 fields: FieldA, FieldB and FieldC, I want to display an object if FieldB only has a single selection and hide the object if FieldB has 0 or 2+ selections. It does not matter what is selected in FieldB, only the quantity.
I am falling at the first hurdle which I think is to extract the selection for the field from the GetCurrentSelection() function. I came up with the following:
=TextBetween(GetCurrentSelections(),'FieldB: ',chr(13),)
This works providing FieldB is not the last selection, because the selections in the GetCurrentSelection are separated by a CR. But if FieldB is the last selection there is no CR at the end of the string.
If someone knows an easy way to do this I would be really pleased, otherwise I need to extract the field selection from the GetCurrentSelection() result in the following circumstances:
No FieldB selection
FieldA: 1,2,3
FieldC: A,B,C
Only FieldB selection:
FieldB: first, second, third
FieldB is the first selection:
FieldB: first, second, third
FieldC: A,B,C
FieldB is the last selection:
FieldA: 1,2,3
FieldC: A,B,C
I'm hoping there is an easy way to do this without a complicated nested if statement.
Thanks in advance.
I got this working with the following statement: If there is only 1 item selected in FieldB this returns the value of the selection in FieldB, otherwise it returns a 0. Surely there is a better, more elegant, faster performing way than this?
=If(if(substringcount(GetCurrentSelections(),'FieldB: ')=1,if(findoneof(TextBetween(GetCurrentSelections(),'FieldB: ',''),chr(13),)=0,TextBetween(GetCurrentSelections(),'FieldB: ',,),TextBetween(GetCurrentSelections(),'FieldB: ',chr(13),),),0)=0,0,If(if(substringcount(GetCurrentSelections(),'FieldB: ')=1,if(findoneof(TextBetween(GetCurrentSelections(),'FieldB: ',''),chr(13),)=0,TextBetween(GetCurrentSelections(),'FieldB: ',,),TextBetween(GetCurrentSelections(),'FieldB: ',chr(13),),),0)='-',0,if(findoneof(if(substringcount(GetCurrentSelections(),'FieldB: ')=1,if(findoneof(TextBetween(GetCurrentSelections(),'FieldB: ',''),chr(13),)=0,TextBetween(GetCurrentSelections(),'FieldB: ',,),TextBetween(GetCurrentSelections(),'FieldB: ',chr(13),),),0),chr(44),)>=1,0,if(substringcount(GetCurrentSelections(),'FieldB: ')=1,if(findoneof(TextBetween(GetCurrentSelections(),'FieldB: ',''),chr(13),)=0,TextBetween(GetCurrentSelections(),'FieldB: ',,),TextBetween(GetCurrentSelections(),'FieldB: ',chr(13),),),0))))
Thanks in advance.
How about this
=GetSelectedCount(FieldB) = 1
Spot on Sunny T - thanks.
I couldn't believe there wasn't an easy way of doing this. Guess I need to refine my search techniques!
Cheers