Copying Cells, Format, etc. - Episode 1.6 | Apps Script ~ Spreadsheet Service

  Рет қаралды 11,390

David Weiss

David Weiss

Күн бұрын

Пікірлер: 13
@fabriciosouza408
@fabriciosouza408 4 жыл бұрын
Man, you're just helping me a lot! I'm from Brazil and I'm learning appscript and you're courses are really great. I hope you keep doing this. Thank you so much for this!
@rameshjangir7393
@rameshjangir7393 2 жыл бұрын
Thanks bro, your script works with little bit of modification as per my requirements, thumbs up.
@myanhdo1562
@myanhdo1562 4 жыл бұрын
thank you so much, i have been looking for this for so longgggg. take care sir
@sergejlust7927
@sergejlust7927 2 жыл бұрын
great topic, thx. Exactly what I needed.
@RajSINGH-si5gt
@RajSINGH-si5gt 3 жыл бұрын
really appreciate your work. thank you so much for such informative videos.
@fredguedespereira4458
@fredguedespereira4458 Жыл бұрын
Thank's for the videos!
@DavidWeissProgramming
@DavidWeissProgramming Жыл бұрын
Glad you like them!
@TheMoOnS38
@TheMoOnS38 3 жыл бұрын
Hi David, thank you so mutch for this video ! Do you think it’s possible to use getActiveRangeList() and copyTo ?
@asimali5820
@asimali5820 3 жыл бұрын
Is there any way to prevent user copy paste in Googlesheet cells??
@davidsebastian9651
@davidsebastian9651 3 жыл бұрын
Hi David, Is there a way to get this work now that copyTo is not supported?
@DavidWeissProgramming
@DavidWeissProgramming 3 жыл бұрын
Hi David, nice name! :) copyTo() is still a supported method in SpreadsheetApp and this code should still run. Is it not working for you? Make sure there are no typos in your own code and you have replaced the value of the "id" variable with the id of your own spreadsheet. If you need more help, feel free to reply with the code you're using along with any errors you may be receiving in the console.
@edu_aqui
@edu_aqui 2 жыл бұрын
Pity it doesn't work copying from one spreadsheet to another. 🙁 It only works between sheets of the same spreadsheet.
@DavidWeissProgramming
@DavidWeissProgramming 2 жыл бұрын
Hi Eduardo! Yes, agreed, unfortunately you cannot use copyTo to copy something from one spreadsheet to another :( However, there are a lot of workarounds for accomplishing this same task! Two I can think of right now is: 1) You can use copyTo() to copy the entire sheet over to your destination spreadsheet, and then once it's there, use the copyTo() method again to copy just the range you wanted to your destination range. Then, you can delete the copied Sheet once you are done. 2) You can use methods like getValues(), getBackground(), getFormula(), getFontColor(), getFontFamily(), getFontSize(), etc. to copy the data and formatting and then use setValues(), setBackground(), setFormula(), setFontColor(), etc. to send it to your destination spreadsheet. Example code is shown below. Option 1: function copyCellAcrossSpreadsheets() { const sourceSpreadsheet = SpreadsheetApp.openById("1BmMuBDWVx0i2TLxVik7rDy5yL5dvwceclZnR679xoaU"); const destinationSpreadsheet = SpreadsheetApp.openById("1qAIEhpYHfVLQ1BwOGb4vBe8QJGyeEkcREZxsEJnINaI"); // Copy entire sheet over const tempSheet = sourceSpreadsheet.getSheetByName("Sheet1").copyTo(destinationSpreadsheet); // Change these numbers around to match the range you're trying to copying const tempRange = tempSheet.getRange(15, 7); const destinationRange = destinationSpreadsheet.getSheetByName("Sheet1").getRange(17, 6); // Copy over contents between sheets tempRange.copyTo(destinationRange); // Clean up, delete temp sheet destinationSpreadsheet.deleteSheet(tempSheet); } Option 2: function copyCellAcrossSpreadsheetsV2() { const sourceSpreadsheet = SpreadsheetApp.openById("1BmMuBDWVx0i2TLxVik7rDy5yL5dvwceclZnR679xoaU"); const destinationSpreadsheet = SpreadsheetApp.openById("1qAIEhpYHfVLQ1BwOGb4vBe8QJGyeEkcREZxsEJnINaI"); // Define source and destination ranges const sourceRange = sourceSpreadsheet.getSheetByName("Sheet1").getRange(15, 7); const destinationRange = destinationSpreadsheet.getSheetByName("Sheet1").getRange(9, 6); // Copy source values and formatting const sourceValues = sourceRange.getValues(); const sourceBackgrounds = sourceRange.getBackgrounds(); const sourceFontColors = sourceRange.getFontColors(); const sourceFontFamilies = sourceRange.getFontFamilies(); const sourceFontStyles = sourceRange.getFontStyles(); const sourceFontSizes = sourceRange.getFontSizes(); // Feel free to get whatever more styles you need... // Copy this to destination range destinationRange.setValues(sourceValues); destinationRange.setBackgrounds(sourceBackgrounds); destinationRange.setFontColors(sourceFontColors); destinationRange.setFontFamilies(sourceFontFamilies); destinationRange.setFontStyles(sourceFontStyles); destinationRange.setFontSizes(sourceFontSizes); } Hopefully this helps! Let me know if you have any questions on the above code.
Autofill - Episode 1.6.1 | Apps Script ~ Spreadsheet Service
5:54
David Weiss
Рет қаралды 3,4 М.
How to Copy a Row to another Sheet with Google Apps Script
15:18
Don’t Choose The Wrong Box 😱
00:41
Topper Guild
Рет қаралды 62 МЛН
1% vs 100% #beatbox #tiktok
01:10
BeatboxJCOP
Рет қаралды 67 МЛН
Move A Row to Different Spreadsheet - Google Apps Script Tutorial
17:17
Solving one of PostgreSQL's biggest weaknesses.
17:12
Dreams of Code
Рет қаралды 222 М.
How to VLOOKUP in Google Sheets with Apps Script?
17:16
Learn Google Sheets & Excel Spreadsheets
Рет қаралды 41 М.
Time Based Trigger - Apps Script | Script Service ~ Episode 3.1
12:42
How To Get Spreadsheet Values Using Google Apps Script
10:24
Amarindaz
Рет қаралды 13 М.
Google Sheets - Clear Contents, Keep Formulas
8:15
Learn Google Sheets & Excel Spreadsheets
Рет қаралды 100 М.