Hello,
I’m looping through a local folder loading excel files into a SQL database.
I’m getting errors when the tab names are different.
Can someone help me adjust the Read Range sheet name to a IF condition?
I would like it to read range if the activesheet is “Sheet1” or “Travelers”.
Any help would be greatly appreciated.
Thanks,
Tim
@timothy.mullady -
1.Use “Get workbook sheets” inside the excel app scope…this will give the all the sheets from the workbook…
Use For Each - and loop through sheets(List) from the step 1
Inside the for each, write if condition like contains(“Sheet1”) or (“Travelers”)
Then use the read range - and use “item” as the sheet name…
Hiba_B
(Hiba Beldi)
March 16, 2021, 3:25pm
3
Hi @timothy.mullady ,
Here is an illustrated example
In the foreach properties, don’t forget to put “string” as a TypeArgument
Hi,
I would suggest instead of If statement, use Switch statement.
It will make your work easy to understand also.
Regards,
Sahil Garg
1 Like
Is there anyway you can show me visual for workflow?
Assign - Array_Files = directory.getFiles()
Loop - For Each Item in Array_Files
Assign - FileName = Path.GetFileName()
Excel Application Scope
Path + FileName
Do
Read Range
etc…
I’m trying to run one sheet. The file generally has one tab “Sheet1” or “Travelers”.
If I set Read Range tab to “Sheet1” and the file has “Travelers” it breaks.
@timothy.mullady - That’s what I told early…you should not set the name of the sheet …it should be from the for each activity…like this.
Give me sometime I will share the workflow…
1 Like
Hiba_B
(Hiba Beldi)
March 16, 2021, 4:21pm
8
Would that help you ?
Sequence.xaml (10.5 KB)
2 Likes
hi Sahil Garg, I don’t think switch statement would be beneficial…because there are two cases, Either “Sheet1” or Travellers" in both the cases user is going to perform the same action…So if you use Switch you end up in copying the same statements to other case which is redundant.
1 Like
Ohh, yes you are right, switch will increase the code in this case.
system
(system)
Closed
March 20, 2021, 2:52pm
13
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.