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

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
m_woolf
Master II
Master II

Macro to select a value in a listbox

I have a listbox which displays items created by and expression (not a field).

How can I select an item in the listbox via code?

3 Replies
matt_crowther
Specialist
Specialist

From the QV API Guide:

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

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

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

Simply wrap in a Sub as normal.

Hope that solves it,

Matt - Visual Analytics Ltd

m_woolf
Master II
Master II
Author

The listbox is displaying the results of an expression, not a field.

pauljohansson
Creator III
Creator III

Michael, maybe this can help.

This Macro makes a selection in a listbox that is based on a expression. The expression results in one row and the macro selects this row. If there is no row in the listbox, a messages is thrown.

sub SelectInListBox


set ListBoxRows = ActiveDocument.GetSheetObject( "LB02" )
IF ListBoxRows.GetRowCount = 1 THEN
set lb = activedocument.getsheetobject("LB02")
lb.selectpossible
ELSE
msgbox("Adjust your Filters to match customers")
end if


end sub

br

paul