How to Automatically Uppercase a Column in Google Sheets
Learn how to automatically convert text in a specific column to uppercase in Google Sheets using Apps Script. This tutorial demonstrates a simple onEdit function that ensures any edits made to the first column are instantly transformed to uppercase.
So we want to uppercase everything in the A column. We have like Andy or Brandy here, but we want it all caps, but anytime we edit it, anytime we go Fred, we want it all caps automatically no matter what we type. So let's go over to Extensions, Apps Script , and do this Over here we're going to write function onEdit with a capital E, and we're going to have an event here as a variable. Now, w- why we do onEdit is this is a built-in function inside of Apps Script that allows us to do something anytime a user edits a cell. So even if we're doing like done or pending, even if we're changing the text in the cell or deleting a little bit of text in the cell, we are going to execute this function . We need to get a row. We need to know what row we're on, so we're going to event. range .getRow Build Your Own PROPER() Custom Apps Script Function to Capitalize Each Word Getting Started Coding in Apps Script Reformat Pasted Cells Automatically Auto Capitalize in Google Sheets
Variable col or short for column equals event. range . 得 column And now we're gonna say if the row is greater than one, because we wanna do this only when we're not editing the header , and column is equal to one, meaning only the first column. We're not gonna use A here, we're gonna use the number one in this programmatic way. But we're also going to check one thing, that there is an event.value. That event.value is the value of the cell that we're changing. Why we do that is because if we're deleting something, we don't wanna uppercase nothing And so we have our conditional here, correct? If all of this is true, we're gonna do something, which is we're gonna do spreadsheetapp dot getactivespreadsheet Get active sheet . Spreadsheet Automation 101 Lesson 2: If ( ){ } and Checkboxes Email When Cell Changes
Make sure we have those parentheses there. We're gonna do . getRange And inside of the range , we're gonna do row, comma, col or column. And we're gonna do set value. We're gonna set the value to event.value.to uppercase. This uppercase is going to be the function that we call to turn all of those characters into uppercase. So we're gonna save this Now we're gonna go back and just check. This Mario Lopez, do we delete something and does it change? Yes, it does. Fred again, and we hit enter, and it changes to all uppercase. So anytime we edit anything in the first column, even John Smith to John Smiths or Fred married John to John, all of this is going to be edited How To Change Date Format Automatically Automate Upper Case
to be all uppercase no matter what. Pretty cool automation, right? You're watching Better Sheets here on YouTube. You have two options here for your next video. Before you go, comment down below if you have any question whatsoever, and I'll make future videos from those questions. But for right here, right now, one of these videos could be your next Google Sheet Better Sheets Videos Checklist Mr Beast Renames YouTube Titles Google Sheets Stories? No! But we'll add timestamped video notes to your google sheets. Auto Capitalize in Google Sheets