• Skip to main content
  • Skip to header right navigation
  • Skip to site footer

My Online Training Hub

Learn Dashboards, Excel, Power BI, Power Query, Power Pivot

  • Courses
  • Pricing
    • Free Courses
    • Power BI Course
    • Excel Power Query Course
    • Power Pivot and DAX Course
    • Excel Dashboard Course
    • Excel PivotTable Course – Quick Start
    • Advanced Excel Formulas Course
    • Excel Expert Advanced Excel Training
    • Excel Tables Course
    • Excel, Word, Outlook
    • Financial Modelling Course
    • Excel PivotTable Course
    • Excel for Customer Service Professionals
    • Excel for Operations Management Course
    • Excel for Decision Making Under Uncertainty Course
    • Excel for Finance Course
    • Excel Analysis ToolPak Course
    • Multi-User Pricing
  • Resources
    • Free Downloads
    • Excel Functions Explained
    • Excel Formulas
    • Excel Add-ins
    • IF Function
      • Excel IF Statement Explained
      • Excel IF AND OR Functions
      • IF Formula Builder
    • Time & Dates in Excel
      • Excel Date & Time
      • Calculating Time in Excel
      • Excel Time Calculation Tricks
      • Excel Date and Time Formatting
    • Excel Keyboard Shortcuts
    • Excel Custom Number Format Guide
    • Pivot Tables Guide
    • VLOOKUP Guide
    • ALT Codes
    • Excel VBA & Macros
    • Excel User Forms
    • VBA String Functions
  • Members
    • Login
  • Blog
  • Excel Webinars
  • Excel Forum
    • Register as Forum Member

Generate multiple output files for multiple input files in the same format|Power Query|Excel Forum|My Online Training Hub

You are here: Home / Generate multiple output files for multiple input files in the same format|Power Query|Excel Forum|My Online Training Hub

vba course banner

Avatar
sp_LogInOut Log In sp_Registration Register
sp_Search Search
Advanced Search|Last Search Results
Search
Forum Scope




Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
sp_Search Search
sp_RankInfo
Lost password?
sp_CrumbsHome HomeExcel ForumPower QueryGenerate multiple output files for …
sp_PrintTopic sp_TopicIcon
Generate multiple output files for multiple input files in the same format
Avatar
Lydia Zheng

New Member
Members
Level 0
Forum Posts: 1
Member Since:
April 1, 2020
sp_UserOfflineSmall Offline
1
April 1, 2020 - 12:35 pm
sp_Permalink sp_Print

I have 50 csv files each with data for a state. Need to perform the same data preparation then generate 50 excel files with a query for each state. I know how to input multiple files from the same folder. My question is: is there a way to general multiple files using power query?

Thank you in advance!

Avatar
Mynda Treacy
Admin
Level 10
Forum Posts: 4517
Member Since:
July 16, 2010
sp_UserOfflineSmall Offline
2
April 2, 2020 - 8:50 am
sp_Permalink sp_Print

Hi Lydia,

No, Power Query can only output data to a single file i.e. the file containing the query. You'd need to create 50 separate query files in order to generate 50 separate Excel files.

Assuming the structure of the CSV files is the same, you could create one Excel file for the first CSV, then copy that file and edit the query to point at the second CSV file and so on for all 50.

Mynda

Avatar
Troy Ridley
USA/Texas/Austin

New Member
Members
Level 0
Forum Posts: 2
Member Since:
February 20, 2020
sp_UserOfflineSmall Offline
3
April 4, 2020 - 6:47 am
sp_Permalink sp_Print sp_EditHistory

I know after you collect all your data and create your proper dataset, you can create a pivot table and make it create 50 separate sheets automatically.  Not sure about different workbooks. 

Avatar
Philip Treacy
Admin
Level 10
Forum Posts: 1529
Member Since:
October 5, 2010
sp_UserOfflineSmall Offline
4
April 5, 2020 - 11:10 am
sp_Permalink sp_Print

Hi Lydia,

If you end up with 50 sheets you can save each one as a workbook using the attached VBA.

Sub SaveSheetsAsWorkbooks()

Dim ws As Worksheet
Dim wb As Workbook
Dim Path As String

' Change this to where you want to save the files
Path = "d:\temp\"
Application.DisplayAlerts = False
Application.ScreenUpdating = False

For Each ws In ThisWorkbook.Worksheets

Set wb = Workbooks.Add
wb.Sheets(1).Name = "xx_OLD_xx"
ws.Copy Before:=wb.Sheets(1)
wb.Sheets("xx_OLD_xx").Delete
wb.SaveAs Path & ws.Name & ".xlsx", xlOpenXMLWorkbook
wb.Close
Set wb = Nothing

Next ws

Application.DisplayAlerts = True
Application.ScreenUpdating = True

End Sub

Regards

Phil

sp_Feed
Go to top
Forum Timezone: Australia/Brisbane
Most Users Ever Online: 245
Currently Online: Dave R, Kumud Patel
Guest(s) 8
Currently Browsing this Page:
1 Guest(s)
Top Posters:
SunnyKow: 1432
Anders Sehlstedt: 873
Purfleet: 414
Frans Visser: 346
David_Ng: 306
lea cohen: 222
Jessica Stewart: 218
A.Maurizio: 202
Aye Mu: 201
jaryszek: 183
Newest Members:
Gilbert Lemek
Ashleigh Farquharson
Jayz Luu
Fred Smith
Charles DeGraffenreaid
Cathi Giard
Sarah Young
Henry Delgado
Alita Nieuwoudt
KL KOH
Forum Stats:
Groups: 3
Forums: 24
Topics: 6360
Posts: 27812

 

Member Stats:
Guest Posters: 49
Members: 32340
Moderators: 3
Admins: 4
Administrators: Mynda Treacy, Philip Treacy, Catalin Bombea, FT
Moderators: MOTH Support, Velouria, Riny van Eekelen
© Simple:Press —sp_Information

Sidebar

Blog Categories

  • Excel
  • Excel Charts
  • Excel Dashboard
  • Excel Formulas
  • Excel PivotTables
  • Excel Shortcuts
  • Excel VBA
  • General Tips
  • Online Training
  • Outlook
  • Power Apps
  • Power Automate
  • Power BI
  • Power Pivot
  • Power Query
microsoft mvp logo
trustpilot excellent rating
Secured by Sucuri Badge
MyOnlineTrainingHub on YouTube Mynda Treacy on Linked In Mynda Treacy on Instagram Mynda Treacy on Twitter Mynda Treacy on Pinterest MyOnlineTrainingHub on Facebook
 

Company

  • About My Online Training Hub
  • Disclosure Statement
  • Frequently Asked Questions
  • Guarantee
  • Privacy Policy
  • Terms & Conditions
  • Testimonials
  • Become an Affiliate

Support

  • Contact
  • Forum
  • Helpdesk - For Technical Issues

Copyright © 2023 · My Online Training Hub · All Rights Reserved. Microsoft and the Microsoft Office logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries. Product names, logos, brands, and other trademarks featured or referred to within this website are the property of their respective trademark holders.