Bring your best ideas to the AI Use Case Contest! Enter to win 40 hours of expert engineering support and bring your vision to life using the powerful combination of Alteryx + AI. Learn more now, or go straight to the submission form.
Start Free Trial

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.

Macro for output the data in excel

akumar2609
8 - Asteroid

Hi Everyone.

I need someone who can help me in creating a macro for my output in excel. I have the below data set where, I want to write the data based on the intercompany in different excel tab of my output file. 

 

CCYLE N AccountS AccountC CenterInter CompanyProductTrans TypeEnding Balance
USDxxxxxxxxxxxxxxx00100-14.1
USDxxxxxxxxxxxxxxx00100-30
JPYxxxxxxxxxxxxxxx0025000040
JPYxxxxxxxxxxxxxxx0025000024
USDxxxxxxxxxxxxxxx00250000-3116.25
JPYxxxxxxxxxxxxxxx00250900110050
AUDxxxxxxxxxxxxxxx00308000-1195
JPYxxxxxxxxxxxxxxx003500001346
USDxxxxxxxxxxxxxxx00350000-2616
JPYxxxxxxxxxxxxxxx0805CN9391500125
USDxxxxxxxxxxxxxxx007501001160
USDxxxxxxxxxxxxxxx0075010041.2
USDxxxxxxxxxxxxxxx090052D760600-998.81
USDxxxxxxxxxxxxxxx00780200418.2
USDxxxxxxxxxxxxxxx090052D789000-355.38

 

My output file is fixed with all the intercompany tab names in it. Below are my requirements:-

 

1) I want this to achieve by macro only

2) All the possible Intercompany names tab will be there in the output file. There are some formula also in each intercompany tabs, so we need to write the data in specified area only i.e. A1 to K20.

3) There are high possibility that we will not get all the Intercompany every time. Hence, I want alteryx to clear the previous data for those intercompany where we do not have the data in current period. 

6 REPLIES 6
ed_hayter
13 - Pulsar

So first i thought this could be done without a macro with an output tool configured to take table name from field. But i think the fact that you want to remove tabs without fresh data requires a macro.

 

So the flow has a block until done to overwrite the whole file with the master data sheet and therefore clear all the tabs from previous version of the file. Then we summarize the intercompany values with summarize these will group our batch macro and send each inter company in one at a time. 

 

 

Within the macro we use the Create new sheet function for each company to get the separate tabs. We get the name of the tabs from the control parameter with the action set to update value and replace specifically Sheet1

image.pngimage.png

akumar2609
8 - Asteroid

Thank you for the reply; however, I am getting the below error message.

 

Error: Append Sheets (2): Record #5: Tool #8: Unable to create backup of C:\Users\nbkjfze\Desktop\Alteryx Examples\Tabbed_Output workflow\Tabbed_report.xlsx to C:\Users\nbkjfze\Desktop\Alteryx Examples\Tabbed_Output workflow\Tabbed_report.xlsx.bak: Access is denied. (5)

ed_hayter
13 - Pulsar

Interesting - this is usually caused by an output tool writing to a file that is already being written to and is therefore locked.

 

I wonder whether a block until done before the output tool in the macro will help with this?

I got that error with that config

A second block until done before the macro:

image.png

seemed to have it running with no errors

CoG
14 - Magnetar

Still not sure why you would need a macro:

Screenshot.png

akumar2609
8 - Asteroid

Hi Andrew,

 

Thank you for replying on my query. 

 

Not sure, I am getting the below error message :- Error: Output Data (6): Unable to create backup of C:\Users\Desktop\Alteryx Examples\Tabbed_Output workflow (1)\Tabbed_report.xlsx to C:\Users\Desktop\Alteryx Examples\Tabbed_Output workflow (1)\Tabbed_report.xlsx.bak: Access is denied. (5)

 

To avoid the above error message, my preference was to move on Macro, however doesn't succeed in that also.

 

Could you help me in getting it resolved?

CoG
14 - Magnetar

Do you have AMP engine enabled? This can occasionally cause that error to be thrown. Try disabling in "Runtime" settings in Configuration pane for workflow. What Alteryx Version are you running?

 

Labels
Top Solution Authors