Published: 2024-06-07 Last Update: 2024-06-07

How to Merge Sheets in Google Sheets

Here, we will create an Apps Script that will merge multiple sheets into one. It will work even though different sheets have different column header casing. Meaning, even if the column header in one sheet is called item and Item on another, it will still work. It will also work even if the columns are not in order. For example, in one sheet, the ordering of columns is: id, item, description and the ordering for another is: ID, Description, ITEM. Our solution should still work even if this is the case.

Let’s get started.

Open your Google Sheets file that contains the sheets that you want to merge. Click Extensions > Apps Script. extensions apps script

You will see a screen like this. This is a Code.gs file where we can put Apps Script codes. apps script code.gs file

Copy this Code.gs file and paste it to replace everything in your Code.gs.

Your Code.gs file will now look something like this. apps script new code.gs file

Click save. apps script save

Back to Google Sheets, refresh the page and wait for the Merge menu to appear. merge menu

Click it, then Start. merge. start menu

Click OK when prompted by Authorization required. invoice extract menu

Login to your Google account. Take note that the title of your Apps Script project will show here. google account login

Click Advanced. advanced

Click Go to <project-name> (unsafe). unsafe link

Take note that the above is fine even if it says not verified or unsafe. It’s your apps script, so it’s fine.

Read the permissions that you will allow (might not be the same as the screenshot) before proceeding. Then click Allow. allow

After authorization, click the Merge > Start again to actually run the script.

Wait for the script to finish. running script finished script

When finished, you’ll have a new sheet named combined that contains all your sheets. combined sheet