Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Macro to select all values

i have two questions for macro for default selections.

1.How to apply a macro to select all values in a particular list box.

2. How to apply a macro to select all values except one  in a particular list box.

Can anyone help me out with code here.

Khushboo

1 Solution

Accepted Solutions
hic
Former Employee
Former Employee

Then you should tell the client that it's a bad solution. Actions are better.

However, the following macro will select all values:

Sub SelectX

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

End Sub

The following macro will select all except September

Sub SelectY

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

ActiveDocument.Fields("Month").SelectExcluded

End Sub

HIC

View solution in original post

5 Replies
hic
Former Employee
Former Employee

No, you should not use a macro for this. Macros often don't work in a server environment. See Macros are Bad.

What you can do instead, is to use an Action. If you want to select all but one value in a field you can do this by first selecting the value to exclude, then "Select Excluded".

Action.png

HIC

Not applicable
Author

Thanks Henric.

But client wants us to use macro only so cant help it.

petter
Partner - Champion III
Partner - Champion III

If you have to use Macros then this gives you some simple examples:

1)

Sub SelectAll

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

End Sub

2)

Sub SelectAllButOne

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

     ActiveDocument.Fields("Month").SelectExcluded     

End Sub

hic
Former Employee
Former Employee

Then you should tell the client that it's a bad solution. Actions are better.

However, the following macro will select all values:

Sub SelectX

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

End Sub

The following macro will select all except September

Sub SelectY

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

ActiveDocument.Fields("Month").SelectExcluded

End Sub

HIC

Not applicable
Author

Thank You  everyone