Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

Alteryx Designer Desktop Discussions

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

Using Macro to apply same procedures on multiple sheets/tabs from one single workbook

Paupau
6 - Meteoroid

Hi champs,

 

I've spent time looking at discussions with similar questions but these seem to be a little too advanced for my understanding. What I would like to do is to apply the same procedures on multiple sheets in the same workbook, and then union them together.

 

I've learnt that using macro would be ideal for a situation like this (as opposed to have multiple input files), but could anyone give a quick example of how I could do this? 

 

Attached is a simplified version of the workflow I did. Essentially I would like something below:

Paupau_0-1576282550736.png

Some technical points to notice:

- In each sheet, the input starts from row 3

- I would like to have the country / tab name as a new column in the output

- Only selective sheets are used (e.g. "Do Not Use" tab in the workbook should not be used)

 

Could anyone shed some light on how I could use a macro to do this? Any help would be appreciated!

 

Best,

Pau

3 REPLIES 3
danilang
19 - Altair
19 - Altair

Hi @Paupau 

 

In many cases, you can apply the same operations to the data from multiple files/sheets without requiring a macro.  Your situation is one of those, since your input is a .xlsx file(so we can get the list of sheet names), and the schema is identical across all 3 sheets (so we can use a dynamic input tool).

w.png

Start by using an Input tool configured to return the list of sheet names and filter out the Do not Use sheet. Use a formula tool to replace "<List of Sheet Names>" with the actual sheet name in each of the paths.  The Dynamic Input tool will read the file once for each the sheets and union the results.  After extracting the Country name from the file paths returned by the Dynamic Input tool, continue with your original workflow.  The only difference required is in the Transpose, where you need to include the Country as one of the key fields.

 

r.png

 

You should learn how to use Macros as well, since you'll eventually come across a situation where you'll need them.  A great place to start is the "Getting Started" series by @EricWe and @SonaliM.    

Getting Started with Standard Macros 

Getting Started with Batch Macros 

Getting Started with Iterative Macros 

 

Dan

 

Paupau
6 - Meteoroid

Thank you very much @danilang !

The workflow I posted is a simplified version of my actual work, which had different schema across the sheets. Therefore I would have to use a batch macro for that.

 

Any guidance on that would be appreciated! Thank you. 

Best,

Pau

BrandonB
Alteryx
Alteryx

Hi @Paupau take a look at the following link for guidance on a batch macro that runs through files with different schemas: https://community.alteryx.com/t5/Alteryx-Designer-Knowledge-Base/CS-Macro-Dev-Reading-in-Multiple-Fi...

Labels