By using this site, you agree to the Privacy Policy and Terms of Use.
Accept
Marketing In Asia
  • Marketing
    • Viral
    • Expert Opinions
    • News & Trends
    • Research
    • Market Podcasts
    • Market Videos
    Marketing
    This category deals with best news and updates on marketing and branding news and events.
    Show More
    Top News
    Sangeeta Mudnal
    How conversational commerce benefits marketers
    1 month ago
    Andrew Monu, VP of Marketing, LinkedIn
    Marketing in Asia Presents an Exclusive Interview with Andrew Monu, VP of Marketing, LinkedIn
    1 month ago
    Ankita Thakur
    Marketing in Asia Presents an Exclusive Interview with Ankita Thakur, Group Head of Marketing, MoneyHero Group
    1 month ago
    Latest News
    Marketing in Asia Presents an Exclusive Interview with Cris Tan, Associate Director, Publisher Development (SEA)
    3 weeks ago
    Time for ASEAN to Rethink a Single Currency Amid Global Trade Tensions
    3 weeks ago
    Marketing in Asia Presents an Exclusive Interview with Carine Chin, Head of Corporate Marketing, Etiqa Insurance Singapore
    4 weeks ago
    Marketing in Asia Presents an Exclusive Interview with April Tayson, Regional VP INSEAU at Adjust
    1 month ago
  • Startup
    • News from Startup world
    • Startup Stories
    • Trends and Opinions
    • Startup Podcasts
    • Startup Videos
    Startup
    News and articles from startup and venture investment world
    Show More
    Top News
    Japan’s Evolving Booze Culture: A Market in Transformation
    Japan’s Evolving Booze Culture: A Market in Transformation
    8 months ago
    text
    Safe Space™ announces partnership with National Healthcare Group as it continues to boost employee support and wellbeing
    9 months ago
    Sakshi Kalani Founder & CEO of Savy Click and Jaipur Unfolded
    AI-Powered Analytics: Sakshi Kalani on Influencer Marketing in 2025
    9 months ago
    Latest News
    Byron J. Fernandez: Minimize the stress of business crises with strong CX
    6 months ago
    Vedant Mahajan Acquires Stake in Flite: Transforming Event Technology with Innovation
    6 months ago
    Navigating the Digital Economy and Tax Challenges for SMEs
    7 months ago
    sehatUP Launches India’s First Integrated Digital Health Clinic, Pioneering Holistic Healthcare
    8 months ago
  • Business
    • Feature Stories
    • News
    • Business Podcasts
    • Business Videos
    Business
    News and press releases from business world of Asia
    Show More
    Top News
    Andrew Monu, VP of Marketing, LinkedIn
    Marketing in Asia Presents an Exclusive Interview with Andrew Monu, VP of Marketing, LinkedIn
    1 month ago
    Ankita Thakur
    Marketing in Asia Presents an Exclusive Interview with Ankita Thakur, Group Head of Marketing, MoneyHero Group
    1 month ago
    Mary Reschar, Head of Product Marketing, Fluent Commerce
    How retailers can prepare for the rise of Gen Zalpha
    1 month ago
    Latest News
    Marketing in Asia Presents an Exclusive Interview with Cris Tan, Associate Director, Publisher Development (SEA)
    3 weeks ago
    Time for ASEAN to Rethink a Single Currency Amid Global Trade Tensions
    3 weeks ago
    Marketing in Asia Presents an Exclusive Interview with Carine Chin, Head of Corporate Marketing, Etiqa Insurance Singapore
    4 weeks ago
    Marketing in Asia Presents an Exclusive Interview with April Tayson, Regional VP INSEAU at Adjust
    1 month ago
  • Society
    • Inspiration
    • Destinations & Travel
    • Food & Gourmet
    • People
    • Young Voices
    • Society Videos
    • Society Podcasts
    Society
    News and articles from and for societies around us
    Show More
    Top News
    Smashers Sports Acquires Delhi Franchise of WPBL: A Game-Changer in India’s Sports Entertainment
    Smashers Sports Acquires Delhi Franchise of WPBL: A Game-Changer in India’s Sports Entertainment
    6 months ago
    Resorts World Cruises Sets Sail from Dubai with New Luxury Gulf Voyages
    Resorts World Cruises Sets Sail from Dubai with New Luxury Gulf Voyages
    8 months ago
    Australia luxury property
    Australia’s Luxury Real Estate Market Soars as Affluent Buyers Seek Waterfront Dreams
    8 months ago
    Latest News
    From Taboo to Triumph: How Malaysians Are Transforming Their Intimate Health Journey
    3 months ago
    Top 5 Misconceptions About Antibiotics Malaysians Need to Stop Believing
    3 months ago
    Eagle Eye Reveals Impact of Loyalty Programs on APAC Retailers
    3 months ago
    Elevate Your Haircare in 2025 with Jung Beauty’s Luxurious Camellia Edition Treatment
    6 months ago
  • Press Release
  • Awards
    • MIA Impact Circle Stellar CxO 2023 Malaysia
    • MIA Impact Circle Stellar CxO 2023 India
    • MIA Impact Circle Stellar CxO 2023 Philippines
    • Australian Women in Business Excellence Awards
    • MIA Impact Circle Stellar CxO 2024 Singapore
    • Mia Impact Circle Stellar Cxo 2024 Hongkong Award 
    • Mia Impact Circle Stellar Cxo 2024 Indonesia Award 
Search
Technology
  • Hot
  • Trending
  • Editor’s Choice
  • NSFW
  • Reactions
  • Authors
  • Viral on Internet
Other Pages
  • My Bookmarks
  • Customize Interests
  • About Marketing In Asia
  • Business Register & Login
  • Web Stories
  • Videos
  • Disclaimer
  • Terms of Service
  • Privacy Policy
© 2024 Marketing In Asia Sdn Bhd. All Rights Reserved.
Reading: Powershell Merge Multiple Excel Files To Single File
Share
Sign In
Notification Show More
Latest News
CleverTap
CleverTap Launches ‘Promos’ – The Industry-First All-In-One Rewards Management Platform
Press Release
Cherry So
HKTDC Maintains 3% Export Growth Forecast
Press Release
adyen
Puma and Adyen Showcase the Speed and Flexibility of Unified Commerce
Press Release
Amazon
Amazon Singapore’s Prime Day Returns in July with First-Ever Week-Long Event from 8 to 14 July
Press Release
HOY
The Trade Desk and HOY Expand Strategic Partnership to Advance Programmatic CTV Advertising in Hong Kong
Press Release
Aa
Marketing In Asia
Aa
  • Hot
  • Trending
  • Editor’s Choice
  • NSFW
  • Reactions
  • Authors
  • Viral on Internet
  • My Bookmarks
  • Customize Interests
  • About Marketing In Asia
  • Business Register & Login
  • Startup Register & Login
Search
  • Marketing
    • Viral
    • Expert Opinions
    • News & Trends
    • Research
    • Market Podcasts
    • Market Videos
  • Startup
    • News from Startup world
    • Startup Stories
    • Trends and Opinions
    • Startup Podcasts
    • Startup Videos
  • Business
    • Feature Stories
    • News
    • Business Podcasts
    • Business Videos
  • Society
    • Inspiration
    • Destinations & Travel
    • Food & Gourmet
    • People
    • Young Voices
    • Society Videos
    • Society Podcasts
  • Press Release
  • Awards
    • MIA Impact Circle Stellar CxO 2023 Malaysia
    • MIA Impact Circle Stellar CxO 2023 India
    • MIA Impact Circle Stellar CxO 2023 Philippines
    • Australian Women in Business Excellence Awards
    • MIA Impact Circle Stellar CxO 2024 Singapore
    • Mia Impact Circle Stellar Cxo 2024 Hongkong Award 
    • Mia Impact Circle Stellar Cxo 2024 Indonesia Award 
Have an existing account? Sign In
Follow US
© 2023 Marketing In Asia Sdn Bhd. All Rights Reserved.
Marketing In Asia > Blog > Society > Inspiration > Powershell Merge Multiple Excel Files To Single File
Inspiration

Powershell Merge Multiple Excel Files To Single File

profile
Last updated: 2022/07/29 at 4:47 PM
Suresh Solomon - UC Acrhitect, Microsoft Teams Voice Engineer Expert and Advanced Powershell Trainer
Share
7 Min Read
powershell-merge-multiple-excel-files-to-single-file
SHARE

Recently I had to merge a few excel files. Usually, I would have done the usual copy and past functions to merge them.

Unfortunately, in this situation I had to merge 10 files and the largest file size was 48MB. The copy paste method would have resulted in errors and I would have to do this multiple times.

I decided to see if I could use Powershell to achieve this. After some research I was able to come up with the following script.

The guide is a step by step so that those new to PowerShell will be able to use the script with some minor modifications.

Let’s begin.

  1. I prefer using Powershell ISE for this script as its easier to edit and execute. Here is how you open it.
  2. You can start Powershell ISE, Windows Start > type “powershell” > right click “Powershell ISE” > Select “Run as Administrator”.

  1. A “Windows Powershell ISE” window will open. If you do not see the edit window or “Script Pane” click on the Arrow beside the “script” on the top right corner.

  1. The working Powershell ISE window will look like this.

PSExcel is a Powershell module we need to enable Powershell to read Excel ( xlsx) files.

To install PSexcel, Powershell ISE must be Run As Administrator or else an error will be returned.

Type the following in the Powershell Script Pane and press the green play button. You will get a dialog window asking to confirm “Execution Policy Change” click “yes”

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope LocalMachine  Install-Module -Name PSExcel  Import-Module psexcel  Get-module psexcel

Here is a screenshot for your reference.

Once we have the Powershell window open, you now need to download the script and sample files. I have prepared a short script to make this easier. You can download all the files using the script below. This will download and extract the files required.

Copy the contents of this script below and paste it on the Powershell ISE Script Pane.

# This script performs the following  # 1. Checks if the download folder exists, creates if it does not already exist.  # 2. specifies the download file name and location to save file.  # 3. Downloads the file from the bitly URL specified.  # 4. Extracts the zipfile contents.  # ###############################    # specify the folder to download the files.  $downloadfolder="C:Excel-merge-script"  # the following checks if the folder exists. If it does not exist the folder will be created.  If(!(test-path $downloadfolder))  {        New-Item -ItemType Directory -Force -Path $downloadfolder  }    # The following specifies the name and the location the file will be saved in.  $output1 = "$downloadfolderSample-Excel-File-for-merging.zip"  $output2 = "$downloadfolderMerge-excel-files-v1.0.ps1"    # these are the location where the files are stored  $url1 = "https://bit.ly/3xmr1Dc"  $url2 ="https://bit.ly/3CTROaQ"    # the next commands will download the files to the specified destination.    (New-Object System.Net.WebClient).DownloadFile($url1, $output1)  #Sample-Excel-File-for-merging.zip  (New-Object System.Net.WebClient).DownloadFile($url2, $output2)  #Merge-excel-files-v1.0.ps1    # expands the Zipped file "Sample-Excel-File-for-merging.zip"  to the folder specified.    Expand-Archive -Path $output1 -DestinationPath $downloadfolder      # End of script.

This is what it will look like.

We are now ready to execute the script.

From Powershell ISE, click on the “File open” icon, browse to “C:Excel-merge-script” and select the file “Merge-excel-files-v1.0.ps1” and click “Open”

Once open, check if the folder name to ensure it matches the current folder. 

You can execute the script by clicking on the Green play button.

Once the script has completed, you will see 2 new files created.You can browse to view if the new files are created.

Now that you have succesfully executed the script, lets look at the source files.

Here are a few points to take note of.

  1. The files have the same columns and in the same sequence. This is critical as the script depends on the column sequence to be the same for all source files.
  2. Each file only has one tab with data, this script does not support mulptiple tabs of excel sheets.
  3. Each file has the “type” that is different. i.e. “IP Phone”, “Hunt Group” and “Analog Phones”
  4. Each file also has different row counts.

Now lets review the merged file “Merged-Excelfile.xlsx”

  1. Take note the “type” column now has data from the source files.
  2. The number of rows matches the sum of rows of the source files.

As you may have different requirements, lets go thru the parts of the script that you can modify to suit your needs.

There are 3 areas that you will need to change.

  1. Declaring the positions of the columns

  1. Populating the variables with the data from the source files.

  1. Creating a custom object ( i.e. new table) with the populated data

Requirements for this script to work for you.

  1. All excel files must only have a single Worksheet with data.
  2. All tables must have identical columns in the same sequence

If you hit any errors, please review the scripts and screen shots provided. There could be an accidental edit that could have caused the error.

Powershell will provide the row the error is generated , that is a good starting point to troubleshoot.

Lastly hope this works for you.

If there is interest I will provide more scripts to acheive different objectives using Powershell.

You Might Also Like

Anant Bhai Ambani’s Vantara Unveils Striking Wildlife Sculptures in Mumbai to Expose the Hidden Threat of Plastic Pollution

Hong Kong Palace Museum Unveils ‘The Origins of Chinese Civilisation’ Exhibition, Showcasing 5,000 Years of History

Superstars of Vantara: Celebrity Voices Champion Wildlife Conservation in Latest Edutainment Series Episode

Influencer Marketing in the F&B Sector: How to Choose the Right Partners

Vantara: Pioneering Global Wildlife Rescue and Rehabilitation, Led by Anant Bhai Ambani

MIA
Get Latest Job Updates on Whatsapp and Telegram
SCIKEY Logo
Whatsapp
Telegram

Sign Up For MIA Newsletter

Be keep up! Get the latest updates about the Marketing world delivered straight to your inbox.

    By signing up, you agree to our Terms of Use and acknowledge the data practices in our Privacy Policy. You may unsubscribe at any time.
    Suresh Solomon - UC Acrhitect, Microsoft Teams Voice Engineer Expert and Advanced Powershell Trainer July 29, 2022 November 26, 2021
    Share This Article
    Facebook Twitter LinkedIn Email Copy Link Print
    Share
    What do you think?
    Love0
    Happy0
    Joy0
    Surprise0
    Sad0
    Angry0
    Cry0
    profile
    By Suresh Solomon - UC Acrhitect, Microsoft Teams Voice Engineer Expert and Advanced Powershell Trainer
    Follow:
    IT Architect specializing in Unified Communications with over 20 years experience. Current interest in sharing my experience in IT Automation. About 7 years ago I was forced to pickup Powershell. It was a challenge in the beginning as I did not have mentors to assist. Learning Powershell allowed me to improve my work efficiency significantly. I hope to share my experience learning Powershell and other IT related matters with the hope it helps someone make working life better. Reach out if you are looking for a Expert IT trainer in Networks, Unified Communications and Powershell
    Previous Article how-to-choose-the-right-cybersecurity-insurance-for-your-business? How to Choose The Right Cybersecurity Insurance For Your Business?
    Next Article what-does-a-marketing-agency-do?-the-benefits-of-hiring-a-marketing-agency What Does A Marketing Agency Do? The Benefits Of Hiring A Marketing Agency
    Leave a comment Leave a comment

    Leave a Reply Cancel reply

    You must be logged in to post a comment.

    9.5k Followers Follow
    3.4k Followers Like
    1.1k Followers Follow
    214 Followers Follow
    208 Subscribers Subscribe

    Latest News

    CleverTap
    CleverTap Launches ‘Promos’ – The Industry-First All-In-One Rewards Management Platform
    Press Release 2 days ago
    Cherry So
    HKTDC Maintains 3% Export Growth Forecast
    Press Release 2 days ago
    adyen
    Puma and Adyen Showcase the Speed and Flexibility of Unified Commerce
    Press Release 3 days ago
    Amazon
    Amazon Singapore’s Prime Day Returns in July with First-Ever Week-Long Event from 8 to 14 July
    Press Release 3 days ago

    PropertyGuru

    property guru

    You Might also Like

    Anant Bhai Ambani’s Vantara Unveils Striking Wildlife Sculptures in Mumbai to Expose the Hidden Threat of Plastic Pollution (1)
    BuzzCampaignInspirationLifestyleOpen Category

    Anant Bhai Ambani’s Vantara Unveils Striking Wildlife Sculptures in Mumbai to Expose the Hidden Threat of Plastic Pollution

    9 months ago
    Hong Kong Palace Museum Unveils 'The Origins of Chinese Civilisation' Exhibition, Showcasing 5,000 Years of History
    EducationEntertainmentInspirationPress Release

    Hong Kong Palace Museum Unveils ‘The Origins of Chinese Civilisation’ Exhibition, Showcasing 5,000 Years of History

    9 months ago
    Superstars of Vantara Celebrity Voices Champion Wildlife Conservation in Latest Edutainment Series Episode
    CampaignEventInspirationLifestylePeople

    Superstars of Vantara: Celebrity Voices Champion Wildlife Conservation in Latest Edutainment Series Episode

    9 months ago
    Satish Bhatia, Co - Founder The Malabar Coast
    InspirationMarketingOpinionPeopleResearch

    Influencer Marketing in the F&B Sector: How to Choose the Right Partners

    9 months ago
    //

    Get Asia to Notice You

    Quick Link

    • Contact
    • RSS Terms of Service
    • Policies & Standards
    • About Us
    • FAQ
    • Disclaimer
    • Terms Of Service
    • Privacy Policy

    Top Categories

    • Marketing
    • Startup
    • Feature Stories
    • News
    • People
    • Inspiration

    Sign Up for Our Newsletter

    Subscribe to our newsletter to get our newest articles instantly!

      Marketing In AsiaMarketing In Asia
      Follow US
      © 2024 Marketing In Asia. All Rights Reserved.
      • Disclaimer
      • Terms of Service
      • Privacy Policy