Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Macro for selecting possible value

Hi!

In my macro I want to automaticaly select a possible value depending on antoher value (obviously) that i've selected manually.

Is this possbile?

Thanks!

//A.

1 Solution

Accepted Solutions
gandalfgray
Specialist II
Specialist II

Hi Annika

You can select all possible values in a field like this:

ActiveDocument.Fields("Month").SelectPossible

If you want to select matching a specific search value:

ActiveDocument.Fields("Month").Select "September"

(selects September)

ActiveDocument.Fields("Month").Select "J*"

(selects January, June, July)

ActiveDocument.Fields("Sales").Select ">1500"

(selects all Sales larger than 1500)

hope this helps!

View solution in original post

16 Replies
montubhardwaj
Specialist
Specialist

Why going for MAcros? you can easily achieve it through Triggers/Actions

gandalfgray
Specialist II
Specialist II

Hi Annika

You can select all possible values in a field like this:

ActiveDocument.Fields("Month").SelectPossible

If you want to select matching a specific search value:

ActiveDocument.Fields("Month").Select "September"

(selects September)

ActiveDocument.Fields("Month").Select "J*"

(selects January, June, July)

ActiveDocument.Fields("Sales").Select ">1500"

(selects all Sales larger than 1500)

hope this helps!

Not applicable
Author

You're both right!

Thank you for your help!

😃

IAMDV
Luminary Alumni
Luminary Alumni

Have you considered using Indirect Set Analysis, which is more faster than macros & triggers.

• p( ) = Possible

• e( ) = Excluded

Example

sum(({<Year={$(=max(Year))},

Customer = p({<Year={$(=max(Year)-1)} Customer>}) Sales)

Cheers - DV

Not applicable
Author

Hi GandalfGray,

       

                I have a similar kind of a requirement.Tried to iimplement whatever you have told but to no effect

   

                 Could you please elobarate on the Macro whatever you have mentioned.Should I take the

                 possible values into a variable.

Regards

Navin Gorapalli

gandalfgray
Specialist II
Specialist II

This is how a subroutine to select the possible values in the field "Month" could be written:

sub SelectPossibleInMonth()

ActiveDocument.Fields("Month").SelectPossible

end sub

then you obviously must call the macro whenever you want

You don't need any variables.

ActiveDocument.Fields("Month") specifies that its your field "Month" that the SelectPossible should be applied for.

Not applicable
Author

Can you shed a little insight on how to accomplish this via and Action?  Thanks!

gandalfgray
Specialist II
Specialist II

Of course!

See the attached application, where possible colors are selected based on which fruit(s) are selected when the button is activated!

selectpossible.JPG

Not applicable
Author

Ahh, I'm sorry - I thought there was a way to do it without a macro.    This will work for m, but I thought Macros were deprecated?