Sort Column in Google Sheet AUTOMATICALLY!
Learn how to automatically sort columns in Google Sheets using various methods, including manual sorting, formulas, and Google Apps Script triggers.
we're gonna sort this column and I'm gonna show you four ways to do it. Definitely the manual way is we can freeze a row up here and in this sales column, which we wanna sort by number , we can click up here and say Sort sheet Z to a Z to means we're sorting from the biggest to the lowest. And there we go. That's one way to sort . But what if we want to keep adding here and we want these months to be in this particular way and we wanna see. What is the highest one on another sheet? So let's create another sheet called Sorted, and we will actually take the exact same style and paste it, but take away all this data and we're going to put into the A column equals sort and the range.
While we're still here, we're going to come in and select . All three of these columns, we can get the whole column . If we just delete that last 11 at the end of there sort column. Now this is gonna be either one, two, or three. We're going to select two, and then we're going to say, is it ascending? And if it's ascending, it'll go smallest to biggest. But if it's descending, it will go biggest to smallest. So we're gonna say false because we do want it to go from biggest to smallest in. And there we go. We have sorted our column. But interesting enough, if we add another month here, Andy, and let's say we'll go big and we'll say, this isn't the next January. We go here and it is sorted here. Great.
But let's say we don't want it on another tab, let's. We might want to delete that or we want to sort this exact one. Let's, let's fix this format a little bit. We're gonna need a app script for this. It can be super easy. I'm gonna walk you through it. We are gonna say sort B column as the name of the function . We're gonna go spreadsheet , app, do get active spreadsheet , do put parentheses there, get sheet by name. And the name of our sheet is sheet one in this particular case. So in parentheses, one put sheet one. I'm gonna say sort , and then we need the column. And here we're going to put the number of the column, not the letter of the column. So we want column two. Now we're gonna save this command S or click the save project to drive up here.
We can click that as well. And when we click run, it's going to sort it. However, we don't want to do that. We don't want to come in here and have to click run. So we're gonna set this up automatically, but just to authorize it and check it. Let's authorize and see is it sorted? Yes, it is sorted , but it's sorted, ascend. So we want to say false here. So two comma false, and let's hit run again. You name this sort . And now it is descending. Perfect. But how do we get this to run automatically? I'm gonna show you two ways to do that. Over on the left side, click triggers, we're going to add a trigger , choose which function , the sort B column from spreadsheet or time driven for right now, I'm gonna do from a spreadsheet and I'm gonna do on edit, click save.
Now every single time I add any data here, it's going to resort. So I can change this to 45 and that automatically did there, even just typing in Andy. Here, we'll resort it. Or if I go one. See, I put it at the top 'cause it's a letter. If I put 10, it's going to resort it every time I edit any cell in the entire. Let's try that again. 22. There it goes. It's resorting it. What's interesting is there's a second way you can automatically set this trigger , so let's create another trigger . But before we go, I'm gonna click the three dots here and click delete trigger . That's how you delete a trigger . If you want to add a trigger , we're gonna use sort B column.
And instead of from spreadsheet , I'm gonna choose time driven, and I'm gonna set this as a daytimer, meaning every single day. And I'm gonna pick a time, maybe late at night or very early in the morning, maybe before we start working, four to 5:00 AM Click save. Now. Every day that same trigger will go, so it won't go while we're editing it. Uh, thankfully, but it will sort every day, so it'll keep our data in sorted every single day. Now again, if you want to delete this trigger , go to the three dots over here, click, delete, trigger , and delete forever. Thanks for watching. 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.