Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Macro or default selection

Hi all,

When we apply macro to select say say two products A and B.

In the current selection it comes as (A|B). but i want it as A,B just like normal selection .

Also if i have a value like age . I apply macro for  selection in age as (""2 years""|""4 years"")

It comes in current selections as ("2 years"|"4 years"). Is there a way to replace this bar in macro script by , and ger rid of these brackets, inverted comas etc?

Thanks

Khushboo

1 Solution

Accepted Solutions
petter
Partner - Champion III
Partner - Champion III

If you do a more elaborate VBScript coding you can get your comma:

Sub SelectMyValues

  Set f = ActiveDocument.Fields("Year")

  Set fv = f.GetNoValues  'empty array

  fv.Add

  fv.Add

  fv(0).Number = 2015

  fv(0).IsNumeric = true

  fv(1).Number = 2010

  fv(1).IsNumeric = true

  If Not( f.SelectValues(fv) ) Then

  ' do some error handling

  End If

End Sub

View solution in original post

5 Replies
petter
Partner - Champion III
Partner - Champion III

If you do a more elaborate VBScript coding you can get your comma:

Sub SelectMyValues

  Set f = ActiveDocument.Fields("Year")

  Set fv = f.GetNoValues  'empty array

  fv.Add

  fv.Add

  fv(0).Number = 2015

  fv(0).IsNumeric = true

  fv(1).Number = 2010

  fv(1).IsNumeric = true

  If Not( f.SelectValues(fv) ) Then

  ' do some error handling

  End If

End Sub

Not applicable
Author

if i have to test for string rather than numberic values?

Can you modify macro for string ?

petter
Partner - Champion III
Partner - Champion III

You change

fv(0).Number = 2015 into fv(0).Text = "2015"

and

fv(0).IsNumeric = false

Not applicable
Author

Thanks Petter 🙂

Not applicable
Author

Petter,

If we have more than 2 values to select .

fv(2).Number = 2011

fv(3).Number = 2012



Like this?