Pasted Range of Values in onEdit – Google Sheets Tutorial
The e.value property passed with the onEdit() function returns "undefined" when a value is pasted in rather than manually typed. To get around this we use the range property and then get the value of the range: function onEdit(e){ const r = e.range; r.setBackground(r.getValue()); } While that works for pasting in a single value it doesn't work for a range. Rather than evaluating at each cell, it applies the evaluation of the top-left value to the entire range. To do that we need to do the following: * Get the number of rows * Get the number of columns * Loop through the rows and columns and: - Access the values - Perform the evaluation The full script can be seen at 4:40, but YouTube doesn't let me use angle brackets in descriptions which are essential for the script. Music courtesy of CORTEXX open.spotify.com/artist/4fOVG4v2qJ38qUbzA4KTY2 #googlesheets #googlesheetstutorial #googlesheetstips #googlesheetsguide https://www.facebook.com/profile.php?id=61571458064705&sk=reels_tab https://x.com/SpencersSheets https://bsky.app/profile/spencerssheets.bsky.social https://www.instagram.com/spencerteachessheets/reels/ I use Bandicam to record, Clipchamp to edit, and a Blue Yeti microphone Donate on Paypal: [email protected]
Download
0 formatsNo download links available.