Members-only tutorial

Watch the video and get the practice sheet with membership.

See membership options

Reformat Pasted Cells Automatically

About this Tutorial

Create uniform formatting even if you're copy and pasting data that is differently formatted.

Video Transcript

<div>0:00 So a member had a very interesting question, and they said basically I don't like that when I cut something like Command X, and I paste it.<br>0:09 I have this blank cell here now This got me thinking about how to fix this and I realized this is not actually necessarily fixable I started trying to create a on edit function Learn about functions and how they can automate tasks in your sheets. Opens in new tab in Apps Script Discover how to use Apps Script to enhance your Google Sheets experience. Opens in new tab where Understand how to filter data using the query where clause. Opens in new tab I took the event that was happening Which is the pasting and found out like what is the format Explore various formatting options to make your data visually appealing. Opens in new tab that it&nbsp;<br>0:31 should be. Um, and this doesn't solve the problem of cutting, but it does solve the problem of pasting.

So I want to show you this interesting solution where Understand how to filter data using the query where clause. Opens in new tab we reformat pasted cells Get insights into working with cells in Google Sheets. Opens in new tab automatically.<br>0:45 Uh, and it solves a different problem. So my solution was not the solution to the first problem, but it is a solution to some problems.<br>0:52 So let's say we have two pieces of a sheet and we're copying and pasting data Learn how to manage and manipulate data effectively in your sheets. Opens in new tab from one place to another, we're trying to like, organize the data Learn how to manage and manipulate data effectively in your sheets. Opens in new tab in some way, but they're formatted in different ways.<br>1:06 So this has an orange background and it's also a different size, we can even make it super small.

And we copy it, not cutting, but just copy.<br>1:14 And we want to paste it here to B4, but we don't want to paste, we could paste special Find out how to use paste special for advanced data pasting options. Opens in new tab values Understand the importance of values in your spreadsheet calculations. Opens in new tab only, we could do that.<br>1:23 But sometimes we don't remember to do that, We just command V, but that if you just notice that it automatically reformatted it.<br>1:33 And so that's what this solution is, is reformatting the cells Get insights into working with cells in Google Sheets. Opens in new tab automatically when you paste.

And actually when you do any edit, um what it does is, first thing is we get all of these four variables.<br>1:48 We need the row, the column, how many rows are in the edit range Learn about ranges and how to reference multiple cells in your sheets. Opens in new tab , how many columns are in the edit range Learn about ranges and how to reference multiple cells in your sheets. Opens in new tab .<br>1:53 And so we're only focusing on when there is only one row and one column, so that doesn't work if it's three columns.<br>2:00 It's high if you're copying and pasting or editing anything, uh that is more than one row one column.

What we're doing is we're taking the existing format Explore various formatting options to make your data visually appealing. Opens in new tab that's at the top of the column and we're going to copy that format Explore various formatting options to make your data visually appealing. Opens in new tab , and just the format only Discover how to apply formatting without changing the cell values. Opens in new tab .<br>2:18 If we are at the top of the column, we're going to get the second row. That's how we sort Learn how to sort your data for better organization and analysis. Opens in new tab of figure it out.<br>2:23 So that's why there's two things here. Basically, if it's more than, if the row number Understand how row numbers work in Google Sheets. Opens in new tab is higher than two, then we're going to grab uh the second uh row.<br>2:35 But if it's actually row two, then we're going to get the third row.

And that allows us now to be able to copy paste data Learn how to manage and manipulate data effectively in your sheets. Opens in new tab somewhere, but automatically reformat it once we have uh pasted it.<br>2:50 So this is really fun. Again, this is uh if you don't remember to copy and paste values Find out how to paste values only to avoid formatting issues. Opens in new tab if you're trying to do something fast or you're trying to do just Command-C, Command-D.<br>3:01 Command-V. And you have these uh weirdly formatted things. Also, helps if I want to reformat this. So let's say I just want to increase the size.<br>3:13 Because that's an edit that will also work. You have to actually edit the value.

So if we edit the value here, then it will edit.<br>3:23 It'll actually change the format Explore various formatting options to make your data visually appealing. Opens in new tab again. So that keeps your data Learn how to manage and manipulate data effectively in your sheets. Opens in new tab well formatted or at least the same format Explore various formatting options to make your data visually appealing. Opens in new tab as you've had before, especially if you're copying and pasting from one place to another.<br>3:34 Actually, this will work the other way as well. If we paste here, it'll work here. Because it's working on every single active sheet Learn about the active sheet and how it affects your data manipulations. Opens in new tab .<br>3:43 If you're a BetterSheets member, you can get this on BetterSheets.co. Down below, you get this exact app script Discover how to use Apps Script to enhance your Google Sheets experience. Opens in new tab and this sheet.<br>3:50 If you're not a member yet, become a member today.</div>