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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
camilo
Contributor III
Contributor III

Macro to create an excel file

Hi,

I´m currently using a macro I found in this forum to create excel sheets, it works perfectly but it just selects the variables from one list box. I would like to select the variables from 2 or maybe 3 listbox (Cat, Zona, Date).

This is the working macro and then is my failed intent to use two list box in one macro, any advice is more than welcome

-- Working Macro --

Sub Export2

rem get Possible Zonas

set ZonaListbox = ActiveDocument.GetSheetObject("LB08")

    Zona=ZonaListbox.GetPossibleValues

rem go through Zonas

for zonacounter = lbound(Zona) to ubound(Zona) 

rem clear previous selections

rem ActiveDocument.ClearAll false

rem Select Zona

ActiveDocument.Fields("Zona_Nueva").Select Zona(Zonacounter)

rem Compose filename

rem file="Employee" & Emps(Empcounter) & ".xlsx"

file="C:\"&"Zona - " & Zona(Zonacounter) & ".xls"

set Chart2Export = ActiveDocument.GetSheetObject("CH18")

Chart2Export.ExportBiff file

Next

ActiveDocument.ClearAll false

MsgBox "Exports Done!"

End Sub

-- Failed Macro --

Sub Export3

set ZonaListbox = ActiveDocument.GetSheetObject("LB08")

    Zona=ZonaListbox.GetPossibleValues

    CatListbox = ActiveDocument.GetSheetObject("LB07")

    Cats=CatListbox.GetPossibleValues

for zonacounter = lbound(Zona) to ubound(Zona) 

     ActiveDocument.Fields("Zona_Nueva").Select Zona(Zonacounter)

for catcounter = lbound(Cats) to ubound(Cats) 

    ActiveDocument.Fields("Cat").Select Cats(Catcounter)

file="C:\"&"Zona - " & Cats(Catcounter)& Zona(Zonacounter) & ".xls"

set Chart2Export = ActiveDocument.GetSheetObject("CH18")

Chart2Export.ExportBiff file

Next

ActiveDocument.ClearAll false

MsgBox "Exports Done!"

End Sub

Thanks!

1 Reply
camilo
Contributor III
Contributor III
Author

anyone?