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

Announcements
Qlik GA: Multivariate Time Series in Qlik Predict: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Compare String of a field in VBA Macro

I am trying to compare fV.GetContent.String to "Individual VaR" in VBA script but didn't get the syntax correctly, can anyone advice?

Sub SelectExp

SET f = ActiveDocument.Fields("_dimension2")
SET fV = f.GetSelectedValues

If (fV.GetContent.String = "Individual VaR") Then
  ActiveDocument.Fields("Exposure Type").Select "INDIVIDUAL VAR"
END If

End Sub

1 Solution

Accepted Solutions
m_woolf
Master II
Master II

Since the "_dimension2" field can have more than 1 selected value, you need to loop through them looking for the string - something like:

set val=ActiveDocument.Fields("_dimension2").GetSelectedValues

for i=0 to val.Count-1

      if val.Item(i).Text) = "Individual VaR") Then

            ActiveDocument.Fields("Exposure Type").Select "INDIVIDUAL VAR"

     end if

next

View solution in original post

1 Reply
m_woolf
Master II
Master II

Since the "_dimension2" field can have more than 1 selected value, you need to loop through them looking for the string - something like:

set val=ActiveDocument.Fields("_dimension2").GetSelectedValues

for i=0 to val.Count-1

      if val.Item(i).Text) = "Individual VaR") Then

            ActiveDocument.Fields("Exposure Type").Select "INDIVIDUAL VAR"

     end if

next