How to Capitalize Names Automatically in Google Sheets
Learn how to automatically capitalize names in Google Sheets using Google Apps Script. This tutorial walks you through creating a function that formats names correctly as you edit them.
Let's auto capitalize names. Anytime we're putting a name into a column, sometimes we'll put in Brandy and not capitalize it. Let's automatically capitalize it. Go up to extensions app script . You'll show up here in App Script . We're gonna create a new function on edit with an event or E Sometimes we make this just the letter E, but for now we'll do event. If we get some pretty cool information here, we get variable row equals event range . Do get row variable column equals event range . Do get column so we know what row, what column we're on. Anytime we're editing or user is editing a cell. And we can say if row is greater than one, meaning it's not the header
row, double ampersand for and call is equal to one, meaning the name column in our particular sheet. What are we gonna do? Well in curly brackets, we're going to do something pretty darn cool. We're gonna run a little bit of JavaScript. I am gonna say constant name equals e range dot get value, do two. We are gonna say E value, or we're gonna say cons titled name equals name two to lowercase split . At the commas at blinks map, word, word, char At zero to
uppercase, we're gonna add word slice one. And we're gonna join at the spaces, and then we're gonna say spreadsheet , app dot, get active spreadsheet , get sheet by name, which is in our case sheet one, get range . It's gonna be the row and the column that we're on set value is gonna be the title name. So we're gonna reset the value based on whatever the value is. We're gonna come in and then we're gonna capitalize it in this sort of title casing, and then we're gonna set that value. So let's see if it works. Let's go, Andrew.
We need event, not e here. Sometimes I mix that up. Let's try again, Andrew. And it's capitalized. Let's try Naomi Campbell and it's perfectly capitalized so we can take John Smith. Paste it again. Delete Mario Lopez, right? Mario Lopez. Right. John Smith. And each time it's capitalizing correctly. That's how to auto capitalize names. Hope you enjoyed that. If you want the app script in this video, just check down below in the description. I'll give it to you absolutely free. Thanks so much. 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.