Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi guys
Is it possible to write a macro which checks whether a particular value is present in a list box or not.
For example if i have a list box of country, i want to check whether Australia is present in listbox or not.
Hi
Depending on what you need to do with the result, you can do that within an expression (incl condition display/calculations) and dimensions without resorting to a macro.
Being present in the list box means that it exists in the field. Or do you mean selected in the list box?
Regards
Jonathan
Hi,
Find below the macro for the same,
Sub Check
vCheck = 0
set v = ActiveDocument.Variables("vYear")
vYear = v.GetContent.String
set table = ActiveDocument.GetSheetObject( "LB01" )
for RowIter = 0 to table.GetRowCount-1
for ColIter =0 to table.GetColumnCount-1
set cell = table.GetCell(RowIter,ColIter)
if vYear = cell.Text then
vCheck = 1
end if
next
next
if vCheck = 1 then
msgbox "Value Matched"
Else
Msgbox "Value Not Matched"
End if
End Sub
Here variable vYear is created to take input from user and checking the same value in field.
Regards,
Kaushik Solanki
Try this macro:
sub findlistvalue
set table = ActiveDocument.GetSheetObject( "LB08" )
for RowIter = 0 to table.GetRowCount-1
for ColIter =0 to table.GetColumnCount-1
set cell = table.GetCell(RowIter,ColIter)
if(cell.Text="India") Then msgbox(cell.Text)
next
next
end sub
Note:
Change the "LB08" according to your list value.
HTH
Sushil