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

FOR each... loop in script

Hi,

I'm trying to load multiple Excel sheets from 1 file, using the FOR loop.

But got a mistake when implemeting it:

FOR Each sheet in 'Sheet 1', 'Sheet 2' 

[Test]:
LOAD F1 as ValueType, 
     F2 as Brand
FROM
[Excel.xls]
(biff, embedded labels, header is 4 lines, table sheet)
NEXT

I think the problem is in sheet naming there - 

(biff, embedded labels, header is 4 lines, table sheet)

 

Any suggestions please? 

Labels (4)
1 Solution

Accepted Solutions
pradosh_thakur
Master II
Master II

(biff, embedded labels, header is 4 lines, table is [$(sheet) & '$'])
or

(biff, embedded labels, header is 4 lines, table is [$(sheet & '$')])

Learning never stops.

View solution in original post

5 Replies
pradosh_thakur
Master II
Master II

Try

(biff, embedded labels, header is 4 lines, table is [$(sheet)])


Have a look.

https://community.qlik.com/t5/QlikView-Documents/Loading-Multiple-Excel-Sheets-Dynamically-along-wit...
Learning never stops.
maxsugak
Contributor
Contributor
Author

Thanks,

I've tried but got error Cannot locate table in BIFF file

pradosh_thakur
Master II
Master II

(biff, embedded labels, header is 4 lines, table is [$(sheet) & '$'])
or

(biff, embedded labels, header is 4 lines, table is [$(sheet & '$')])

Learning never stops.
pradosh_thakur
Master II
Master II

Try Below
FOR Each sheet in 'Sheet 1$', 'Sheet 2$'

[Test]:
LOAD F1 as ValueType,
F2 as Brand
FROM
[Excel.xls]
(biff, embedded labels, header is 4 lines, table is [$(sheet)] )
NEXT
Learning never stops.
maxsugak
Contributor
Contributor
Author

The second one works, thank you!