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 loop and create varaibles

Hi,

I am trying to loop and create variables.

How is the syntax for adding the loop number to variable names:

My macro:

sub var
set v = ActiveDocument.Variables("vCountrows").GetContent.String


for i = 0 to v

ActiveDocument.Fields("Vtif2").select(v)


ActiveDocument.CreateVariable "vIntime"
ActiveDocument.Variables("vIntime").SETCONTENT ActiveDocument.Fields("intime").GetPossibleValues.item(0).text,TRUE

ActiveDocument.CreateVariable "vOuttime"
ActiveDocument.Variables("vOuttime").SETCONTENT ActiveDocument.Fields("outtime").GetPossibleValues.item(0).text,TRUE

ActiveDocument.CreateVariable "vDep"
ActiveDocument.Variables("vDep").SETCONTENT ActiveDocument.Fields("depatment").GetPossibleValues.item(0).text,TRUE


next
end sub

My wish is to add the number from the loop to the variable name: after först round it should be vIntime1, vOuttime1 and vDep1

How can I add this to the macro?

Liivi

0 Replies