UnMerge Automatically Google Sheets
Learn how to automatically unmerge cells in Google Sheets using a simple Apps Script function that runs on a timer, ensuring your sheet stays organized without manual intervention.
you have some merged cells and you want to un merge them and you wanna un merge them automatically. Of course, we could go to the sheet, we could select everything. We could go to this merge cells , click this select merge type, and we could click un merge . That is totally possible. But what if we want to do it all the time? What if someone keeps merging our header and we want to unmerge it even when we're not using our sheet? Let's do that in this video. So we're gonna click extensions app script, click okay. This is gonna be super simple. We're gonna call this function Unmerge Me. We're gonna have a variable SS equals spreadsheet. Do get active spread. Get sheet by name and we're gonna call this merged. So that's just the name of the spreadsheet. We want to unmerge everything all of the time.
And now here is the one line of code. I guarantee you this is gonna be quick. We go ss get range . We start in row one, column one and we go to SS dot get max rows ss.gi max columns. That's the entire sheet. And we go break apart. That's dot break apart. We're gonna save this. Now we're going to test it by running it. Once we click run, we're going to authorize and we're gonna see that it works one time. So click run, and there it is. It has worked. So we know it works, but we want to automate it. Go over to the left side of your app script . Click on triggers. Go to the bottom right click add trigger . We're gonna choose which function to run. If you have more functions here, you're gonna choose the one that we've selected here, unmerge Me that we created, and the event source.
We're gonna change that to time driven. We're going to change hour timer to minutes, timer or Daytimer. If you wanna run this once a day or every hour, I'm gonna keep it an hour. I'm gonna run it every hour. I'm gonna click save now that. Sheet will only stay merged for an hour if somebody comes in and merges it without my direction. And there it is, a trigger to unmerge everything. Now, if you do want something merged and you wanna delete this trigger , just come back to triggers in app script . Click on the three dots over here on the right, click delete trigger , and now we can delete that trigger forever if you do end up wanting to merge something. But that's it. That's the entire code here. pick the sheet. Get the range break apart. Now you can unmerge all the time. You are watching better sheets here on YouTube.
Make sure you check out this video or this video and subscribe right now to get more tips, tricks, how tos, get more out of your Google sheets than you ever have before. I'm excited to be making a ton more videos here. Ask me questions down in the comments and I will answer them in future videos. But for right now, right here, one of these videos is gonna be your next Google sheet.