Forum Discussion

Rahul_SC's avatar
Rahul_SC
Helper IV
4 years ago
Solved

How to split a master file into many excel workbook based on a column

Hi all,

 

I have a masterfile in excel. I want to split this file into many excel workbooks.  As a sample, below is the table. I want to split this table into excel workbooks based on Column (Subject), so in this condition, I should get two workbooks as there are two different subjects in column (Subject). 

NameSubjectsMarks
AMaths12

A

Science23

B

Science21

B

Maths25

 

Thanks!

  • Power Query is not the right tool for this as it doesn't produce different Excel files. You will have to do quite a manual work and save all files one by one after applying different filters in PQ.

     

    Right tool for this is Excel itself if you want automated version. 

    I have written a VBA macro in which you need to select the column and it will generate those many files corresponding to distinct entries. Hence, if you run macro after selecting Subjects column or just selecting any cell in Subjects column, you will get two files.

    Article 48 – Split A Workbook into Multiple Workbooks on the basis of a Column

    If you are doing some transformations in PQ, do it and save the output in an Excel. Then run the above macro.

5 Replies

  • Vijay_A_Verma's avatar
    Vijay_A_Verma
    Most Valuable Professional

    Power Query is not the right tool for this as it doesn't produce different Excel files. You will have to do quite a manual work and save all files one by one after applying different filters in PQ.

     

    Right tool for this is Excel itself if you want automated version. 

    I have written a VBA macro in which you need to select the column and it will generate those many files corresponding to distinct entries. Hence, if you run macro after selecting Subjects column or just selecting any cell in Subjects column, you will get two files.

    Article 48 – Split A Workbook into Multiple Workbooks on the basis of a Column

    If you are doing some transformations in PQ, do it and save the output in an Excel. Then run the above macro.