Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Conditional macro in QV

I have the following list boxes:

Screen Shot 2016-02-27 at 10.32.51.png                        Screen Shot 2016-02-27 at 10.33.01.png

I need to run a macro in QV on condition that a user makes a selection in any of the above two list boxes.  I have the following individual macros which work individually:

Screen Shot 2016-02-27 at 10.31.54.pngScreen Shot 2016-02-27 at 10.32.14.png

How can these two be combined to achieve my objective?

Regards.

Chris

1 Solution

Accepted Solutions
Not applicable
Author

Set fld and fld2 as you have already and then...

          IF (fld.GetValueCount(1) * fld2.GetValueCount(1)) = 0 then

              msgbox "Please select....

If either or both are zero then the result of multiplying becomes zero.

If you only want to do the message when one is selected and the other not,...

          IF (fld.GetValueCount(1) * fld2.GetValueCount(1)) = 0 AND _

               (fld.GetValueCount(1) + fld2.GetValueCount(1)) <> 0 then

              msgbox "Please select....

...that second bit prevents the message when both are unselected.

View solution in original post

3 Replies
Not applicable
Author

Set fld and fld2 as you have already and then...

          IF (fld.GetValueCount(1) * fld2.GetValueCount(1)) = 0 then

              msgbox "Please select....

If either or both are zero then the result of multiplying becomes zero.

If you only want to do the message when one is selected and the other not,...

          IF (fld.GetValueCount(1) * fld2.GetValueCount(1)) = 0 AND _

               (fld.GetValueCount(1) + fld2.GetValueCount(1)) <> 0 then

              msgbox "Please select....

...that second bit prevents the message when both are unselected.

Anonymous
Not applicable
Author

Ended up using two different sheets and two different macros.

Regards

Anonymous
Not applicable
Author

Many thanks Mark, this works fine