Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Macro to spilit the data and save

Example:

I have data from different country.

I would like to spilit the data based on country and save the file based on Country using Macro.

sub Country_Reduce
set vfield=ActiveDocument.Fields("Country")
vfield.select "USA", true
ActiveDocument.ReduceData false
ActiveDocument.SaveAs "C:\Users\USA.QVW"
end sub

the above statement works for one country.If I need to implement the same for multiple countrywise -I tried to loop .

It didn't work.

Advance thanks for help.

1 Reply
Anonymous
Not applicable
Author

Hi

You can done this with use of for next loop

Just alter you coding like below .

sub Country_Reduce

set vfield=ActiveDocument.Fields("Country").GetPossibleValues()

for vselectvalue=0 to vfield.count-1

ValueToSelect = vfield.Item(vselectvalue).Text

msgbox ValueToSelect

ActiveDocument.Fields("Country").select ValueToSelect

ActiveDocument.ReduceData false

ActiveDocument.SaveAs "D:\san\"&ValueToSelect&".QVW"

next

end sub

here you can change the saveas path but dont change the variable because the variable have the list of country name.

Regards

Ashok