Copy and Paste Range Values from one Google Sheet into another with Google Apps Script

Поділитися
Вставка
  • Опубліковано 26 лип 2024
  • Here is a link to the starter template:
    docs.google.com/spreadsheets/...
    You can get the written tutorial here, along with some bonus material on formatting imported data:
    yagisanatode.com/2022/02/22/c...
    In this tutorial, we cover how to paste a complete set of Google Sheets range values from one Google Sheet to another with Google Apps Script. This tutorial is essentially an Apps Script alternative to the Google Sheets IMPORTRANGE function.
    00:00 Intro
    00:16 Apps Script over IMPORTRANGE
    00:36 Setting up your Google Sheets
    02:04 Writing the runsies() function
    06:45 The importRange() function
    16:53 testing the script
    17:26 Applying to multiple import range instances
    18:14 Adding a time trigger
    19:32 Other approaches
    You can find out more about how to append and manipulate Google Sheets data in these tutorials:
    - Google Apps Script - Copy Selected Columns in One Sheet and Add Them To The Bottom of Different Selected Columns in Another - yagisanatode.com/2018/11/17/g...
    - Google Apps Script: Get the last row of a data range when other columns have content like hidden formulas and check boxes [updated Dec 2021] - yagisanatode.com/2019/05/11/g...
    - Google Apps Script Course - Part 1: 2D Array Data Transformation of Single Question Item Data to Total Count of Choices in Google Sheets - Google Apps Script Course - Intro: 2D Array Data Transformation for Google Sheets - yagisanatode.com/2019/12/22/g...
    - Creating Unique Ranges from 2D Arrays in Google Apps Script - yagisanatode.com/2020/10/26/c...
    - Google Apps Script: Add and removed Google Sheets columns based on a search array - yagisanatode.com/2020/03/28/g...
    If you like the video, check out my website:
    yagisanatode.com/
    Here is the link to just Google Apps Script tutorials:
    yagisanatode.com/google-apps-...
    Get your copy of the Google Sheet Project Task Manager here: yagisanatode.teachable.com/p/google-sheets-project-tasks-manager
    #GoogleSheets #GoogleWorkspace #GoogleAppsScript #AppsScript #Spreadsheets

КОМЕНТАРІ • 136

  • @pjohnson21
    @pjohnson21 Рік тому +2

    This was SO helpful, thank you! Very methodical and easy to follow. Exactly what I was looking for.

  • @Bafa
    @Bafa Рік тому +2

    Utterly amazed. I usually have to search and piece together bits from different videos and then only sometimes can I get the code to work. You have made a video on the exact thing with everything I needed. Even using the time function. Made my life so much easier!

    • @yagisanatode
      @yagisanatode  Рік тому

      Thanks Allen. I know the feeling. I'm glad you found a match for the project you are working on. Happy coding!

  • @HamiltonRichards
    @HamiltonRichards 10 місяців тому +2

    Very nicely done-clear, concise, and well organized.

  • @bytetonesbytetones3083
    @bytetonesbytetones3083 Рік тому +2

    You are the man! Thanks so much, great video!

  • @MrChrisgapo
    @MrChrisgapo 2 роки тому +1

    Thanks Scott. Nice content and very helpful. New subscriber here! :)

  • @MatthewGigantelli
    @MatthewGigantelli Рік тому +1

    you are so easy to follow along with. Great tutorial I appreciate it

    • @yagisanatode
      @yagisanatode  Рік тому

      Awesome to hear. Glad you found the tutorial useful!

  • @sophiauwoziya9765
    @sophiauwoziya9765 Рік тому +2

    This came timely! Thanks a lot.

  • @exceladvisor29
    @exceladvisor29 2 роки тому +1

    Appreciations from Pakistan :) Thanks for giving such awesome work👍

  • @jeremyross7641
    @jeremyross7641 Рік тому +1

    Great video. Thank you

  • @lordAlpargata
    @lordAlpargata 2 роки тому +1

    Wow you rule 💪 I was able to do it, thank you very much!

  • @KenanAnt
    @KenanAnt 2 роки тому +1

    Scott thanx for video. Good job..

  • @Allsmort
    @Allsmort 2 роки тому +1

    This was so useful today thank you very much.

  • @user-el2ey6ef3f
    @user-el2ey6ef3f Рік тому

    very helpfull, dude, thanks for the video

  • @aishahakpk237
    @aishahakpk237 Рік тому +1

    tq very much for the knowledge 👍🏻

  • @user-py9is1xm9e
    @user-py9is1xm9e 5 місяців тому +1

    I am from indonesia. Great tutorial I appreciate it

  • @rosebellbicar1125
    @rosebellbicar1125 2 роки тому

    This is amazing. Will this work if you have a table format and you wanna copy the values only on a specific cells in transpose format?

  • @gp9651
    @gp9651 Рік тому

    Thank you very much. Is it possible to import only particular columns? For example "A, D, CJ"?

  • @hetalbedwal3988
    @hetalbedwal3988 2 роки тому

    Thanks for sharing such a wonderful script!! I have a query to ask in this, if we want to import same sheet but different columns how do we do that?? is there a way to add multiple columns from the same Sheet ( Source & destination Sheets are same)

  • @marcosrs75
    @marcosrs75 Рік тому +1

    You’re good, thanks for the great tutorial! I’d like to suggest a subject for a future video. Since Google Sheets do not allow to use formulas that returns a list of items in data validation, I have a LOT of work on this specific matter.
    I think a script that gets a comma separated list in a cell (e.g. D3) and apply them to a range all the way down (e.g. D6:D) as data validation - and then repeat that on all columns to right - would be really great. Thanks!

    • @yagisanatode
      @yagisanatode  Рік тому +1

      Hi Marcos, great idea. I have quite a backlog of videos ahead, but that's definitely one to put on the list.

  • @igorremesz7310
    @igorremesz7310 Рік тому +2

    Hey Yagi, great tutorial - thank you so much, made my task much easier! :) Do you think you could prepare a tutorial for a case when you need to copy specific cells in a column (as in getRangeList or something along the lines) and copy them to a different Google Spreadsheet, also passing a list of cells to be pasted into? That would be wonderful as I cannot find any solution online that works for my case. Have a great day!

    • @yagisanatode
      @yagisanatode  Рік тому

      Hi Igor, I can add this to the list. It might take a little time to get to though. A couple of clarifying questions.
      So you are looking to copy values from selected cells in a range or the entire column? How do you want to determine which cells/columns that will needed to be selected?

    • @igorremesz7310
      @igorremesz7310 Рік тому

      @@yagisanatode Hi, thanks for replying - I want to copy a selected range of cells (eg. I25, I67, 68, etc.) from workbook A sheet 1 (by ID and sheet name) to a selected range of cells (eg. B12, B25, B40) to a different workbook and sheet (by ID and name). In my case I determine which cells I need to copy fromto empirically :) Copying an entire column, or a fixed range, is very straightforwadly explained in this tutorial, my case however, seems a bit complicated as I have searched numerous stack threads and was not able to come up with a solution that would fix my problem. Hope that clears it up a bit. Best to you!

  • @dmeyufta3415
    @dmeyufta3415 2 роки тому +1

    thats great video for learning and i have learned thourgh it
    i wants to ask like if we wants to copy the data many times and wants to put them one below other (append) so how it will be done by this script.

    • @yagisanatode
      @yagisanatode  2 роки тому

      Hi DME YUFTA, thanks for the kind words. That is definitely the topic of another video tutorial. The short answer is that you can use something like the appendRow() method ( developers.google.com/apps-script/reference/spreadsheet/sheet#appendRow(Object) ).
      The long answer is that there are other things that may impact the way you append a row. If you might have multiple users who may be appending the row all at once, then you should probably implement something like LockSerivce ( developers.google.com/apps-script/reference/lock?hl=en ). Also append will fail if you have hidden formulas in your sheet that appear when there is data in a row. So you might need to get the first emply row in a column with ( yagisanatode.com/2019/05/11/google-apps-script-get-the-last-row-of-a-data-range-when-other-columns-have-content-like-hidden-formulas-and-check-boxes/ )
      Hope this helps.
      ~Yagi

  • @ajscx
    @ajscx 2 роки тому +1

    Awesome

  • @balbina5859
    @balbina5859 Рік тому +1

    Thanks Yagi. This is helpful. :) Now, I would like to set the destinationRangeStart as a variable based on a first empty row available in the destination sheet. This will let me save the historical data log (aka screenshots) of the input data rows which are changing daily.
    Could you please help with that?
    Thanks!

    • @yagisanatode
      @yagisanatode  Рік тому +2

      Hi Balbina, Yes in short take a look at either the .getLastRow() method or .getNextDataCell() methods. I have some tutorials in the description of the videos to help you go a little further, but this one will probably be the best for your needs, yagisanatode.com/2019/05/11/google-apps-script-get-the-last-row-of-a-data-range-when-other-columns-have-content-like-hidden-formulas-and-check-boxes/

  • @justinprimmer2274
    @justinprimmer2274 Рік тому +1

    This video was amazing! At the end of the video you mention going over filtering empty spaces in future videos but I can't seem to find them. Have you made them yet or are they still in the works?

    • @yagisanatode
      @yagisanatode  Рік тому +1

      Hi Justin. Unfortunately I haven't yet. There are a few similar written tutorials on my site (Links in description), that might point you in the right direction for the time being. I've added this to my priority list, but projects have kept me pretty busy, hopefully get a video out in the next few months.

  • @michaelhaj1
    @michaelhaj1 2 роки тому

    Great stuff! Thank you for this. Is there a way to rather set a specific destination sheet to create a new sheet named as date and paste the data there? I've adjusted the code so it pastes the data to next empty row but the new sheet thing is way too advanced for me :( thanks for any ideas!

    • @yagisanatode
      @yagisanatode  2 роки тому +1

      Great work modifying the code, Michael.
      Yes you can check out SpreadsheetApp.create() developers.google.com/apps-script/reference/spreadsheet/spreadsheet-app#createname,-rows,-columns
      You can generate a date with something like const myDate = new Date() developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/Date
      You can even change the date to a specific format with .toLocalDateString() developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleDateString
      Hope this helps!

  • @alien3303
    @alien3303 Рік тому

    If I basically want to copy and based information inside selected cells from one sheet to another what would be the code .I need to be able to select what information I want to transfer to the other sheet and need to select certain columns where the information would go

  • @papisnipe3022
    @papisnipe3022 2 роки тому +2

    This is so useful, my boss will like it!
    For this case: Copy Selected Columns in One Sheet and Add Them To The Bottom of Different Selected Columns in Another, how can you select cells out of a column, full of hidden formulas, which are not hidden?

    • @yagisanatode
      @yagisanatode  2 роки тому

      Hi Papi,
      You might find this tutorial helpful:
      yagisanatode.com/2018/11/17/google-apps-script-copy-selected-columns-in-one-sheet-and-add-them-to-the-bottom-of-different-selected-columns-in-another/

  • @sumadoolpeep7171
    @sumadoolpeep7171 Рік тому +1

    Thank you very much for this tutorial! I was wondering, can this script also be applied to other sheets in the same google sheet file? and if yes, could it be manipulated also within each individual sheet while it updates the master sheet? or is it only possible to manipulate the master file and it updates in the destination/sheet?

    • @yagisanatode
      @yagisanatode  Рік тому +1

      Yes you can! You can use the getRange() method or the copyTo() methods locally to do this. Check our the other tutorial links in the description for some more guides on working with data in Google Sheets with Apps Script.

  • @SanjaySingh-zp9uv
    @SanjaySingh-zp9uv 2 роки тому +2

    Nice content really useful!
    Can we apply filters on the imported data?
    I have been searching on this, how to apply filters on the imported data, but we are not able to do so since the data imported is dynamic which means the data will not be filttered it will automatically convert back to its original imported form.
    Any ideas how to do that?

    • @yagisanatode
      @yagisanatode  2 роки тому +1

      Hi Sanjay, yes we can use the filter class to apply new filters. developers.google.com/apps-script/reference/spreadsheet/filter
      Just keep in mind that this Apps Script approach is different to Google Sheets IMPORTRANGE in that it can be filtered directly.

  • @palyamreddisekhar3475
    @palyamreddisekhar3475 2 роки тому +1

    Nice content thank you so much!
    I'm trying to append data from two different to single sheet and without blank rows. can you please provide solution here?
    Thanks in Advance!🤞

    • @yagisanatode
      @yagisanatode  2 роки тому +2

      Hi Palyam, I haven't got a tutorial specifically to your needs just yet, but I can point you in the right direction. Your best bet here is to gather the data from both sheets with something like .getRange() or getRangeByName() methods then get the values with .getValues(), find thein common column, e.g. an id or a name and combine them together with a loop like for or forEach or use the map funcitonal method.
      Next, you can get the last row a number of ways. The easiest being getLastRow(). If you also have a bunch of hidden formulas in other columns you might be better off using the approaches in the link below.
      Then use getRange(your last row, your col start, yourData.length, yourData[0].length),setValues() to append your data. yagisanatode.com/2019/05/11/google-apps-script-get-the-last-row-of-a-data-range-when-other-columns-have-content-like-hidden-formulas-and-check-boxes/

  • @exultdocs9350
    @exultdocs9350 2 роки тому +1

    Thanks, Scott; This program is very useful. Can you please suggest how to copy the selected columns or copy the entire sheet except for a few columns by modifying the given program?
    Can this program be modified to..1.Only changed row gets updated, Append /copied rows in destination based on some condition in the source file. ;

    • @yagisanatode
      @yagisanatode  2 роки тому

      Hi, you might find this tutorial helpful:
      Google Apps Script - Copy Selected Columns in One Sheet and Add Them To The Bottom of Different Selected Columns in Another [updated Feb 2022]
      yagisanatode.com/2018/11/17/google-apps-script-copy-selected-columns-in-one-sheet-and-add-them-to-the-bottom-of-different-selected-columns-in-another/

  • @DJJeSta09
    @DJJeSta09 Рік тому +1

    Thanks for the video. I am fairly new to this. Basically i am trying to find instructions on how to do a copy script for a specific set of cells (H7:J7) and then copy them to the next available row in columns C,D,E all on the same sheet. Do you have a video that covers that?

    • @yagisanatode
      @yagisanatode  Рік тому

      Hi Dean. I don't have anything that specific. You can use the getRange() and then getValues() methods like in the video. To paste them in the new location, you safest approach would be with this tutorial, yagisanatode.com/2019/05/11/google-apps-script-get-the-last-row-of-a-data-range-when-other-columns-have-content-like-hidden-formulas-and-check-boxes/

  • @user-ls2et6th5v
    @user-ls2et6th5v 7 місяців тому

    This is awesome. How would we go if you'll only filter what to transfer to the destination sheet based on a criteria or keyword?

    • @yagisanatode
      @yagisanatode  7 місяців тому

      Are you looking to copy only the values displayed in the filter across to the destination sheet?

  • @rifdahfadhilah1137
    @rifdahfadhilah1137 Рік тому +1

    thank you very much for this video. it helps me a lot.
    is it possible to paste the data to different sheets in one spreadsheet every time we run it and non syncing it from the data source?
    im trying to make a monthly database with clear spreadsheet source every month so the pasted data cannot be synced with the origin database.
    do you have any idea how to do that?

    • @yagisanatode
      @yagisanatode  Рік тому

      Hi rifdah, I don't think that I am 100% sure what you you mean in the second part of your first question, sorry, but I will try to answer. Yes you can copy and paste date to other sheet tabs in the same spreadsheet. You can set up different scenarios or conditions by which to update them and even use simple triggers like onEdit or onChange or time triggers to schedule events to up update your sheet tabs.
      I have some more tutorials in the links in the description on my website and also info on triggers.
      I hope this helps a little.

  • @jaypeevicente8224
    @jaypeevicente8224 Рік тому

    Hi! This tutorial is the best! I have encountered an issue with big data and the appscript is timing out... Can you give us a resolution for this, please? Thanks a lot!

    • @yagisanatode
      @yagisanatode  Рік тому

      Without seeing how you retrieve your data, there are a few things you can do.
      1. You made find that the Google Drive Advanced is a little more performant by sending a batchupload request.
      3. Grab the data by n length of rows at a time. Keep track of the time it takes to complete each process and keep track of the last row of each range that you collected using PropertiesService. After a few test runs you will figure out an optimal range to copy and paste at a time. As you approach your time-out period (6 minutes), create a time trigger to run ever minute and every minute repeat the process until the script is complete.
      Hope this helps.

  • @mythstqn
    @mythstqn Рік тому +1

    Thanks for your sharing, my case I have 40 different google sheet files with sheets named ABC
    I want to put together a file that joins these data into sheets called EFG and every day the data is automatically updated without me having to open the file. Thanks for your help

    • @yagisanatode
      @yagisanatode  Рік тому

      You're welcome! Interesting use-case. Thanks for sharing!

  • @muhamadekocahyono2661
    @muhamadekocahyono2661 Місяць тому

    Thank you for your video. I watched till the end.
    And now I feel curious. Can the user copy paste data to other Google sheet (as destination) but only if tick box is check box.
    And data which pasted to the Destin is editable

  • @maze7653
    @maze7653 2 роки тому +1

    Hello! I really liked your script and this is exactly what I needed, but I have only one problem. I lack script skills (I'm sorry) and I have searched already for a way to delete only rows A1 and B2 before pasting the data on destsheet but even trying a lot before without help I only got errors, can you please help me with this issue?

    • @yagisanatode
      @yagisanatode  2 роки тому

      Hi Maze, once you getValues() you can use JavaScript slice or splice to remove those selected rows before using setValues() to paste it into your new sheet.
      developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice
      developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/splice
      Have a try using these methods and if you get stuck feel free to add a copy of your attempt and either I (time permitted) or a reader can guide you in the right direction.

  • @dopdopno2007
    @dopdopno2007 2 роки тому +1

    Hi sir, i would like to thank you for this very wonderful guide. Its really amazing and i really helped me a lot.
    Now, my problem is we have added 2 different g sheet files.
    Will you be able to make a video like this, that shows us how to import data from 5 different g sheets file and consolidate it to 1 file.
    For example:
    There are 5 different places/site that is doing an attendance for employees, so i need to consolidate them in my file by using appscript.

    • @yagisanatode
      @yagisanatode  2 роки тому +1

      A tutorial on collecting data from multiple sheet and storing it in a destination sheet sounds like a good tutorial. I'll add it to my list.

    • @dopdopno2007
      @dopdopno2007 2 роки тому

      And also, if possible please make it user friendly as i have my team mates also using the masterfile, so it will be very nice if all users in the masterfile have the ability to run the code by just clicking the button.

  • @noemimesesan1054
    @noemimesesan1054 2 роки тому +1

    Is there a way to import data into the destination and the destination to not change on the existing data ? So if I delete something from the Source to still have it on the Destination

    • @yagisanatode
      @yagisanatode  2 роки тому

      You sure can. I have done something similar to this in this tutorial: yagisanatode.com/2019/02/13/google-apps-script-when-i-add-a-value-to-a-cell-in-a-selected-column-i-want-it-to-move-to-another-google-sheet/

  • @DominiqueMoons-x3i
    @DominiqueMoons-x3i Місяць тому +1

    Very nice. This is what I was looking for.
    But I have a question.
    You use a fixed ID for the source ID. Is it possible to place a changing ID here? My source file changes every week and so does the source ID. You choose the file and get the ID that can then be used as the source ID.
    Thanks

    • @yagisanatode
      @yagisanatode  Місяць тому

      Yes you can. You could add the IDs to reference cells or an input dialogue and reference them. Use the openById() method in this case.

  • @MichaelDaniels
    @MichaelDaniels Рік тому +1

    Not sure if you have a video like this but here goes..... We have in one sheet a row with a "work order number" . We want to copy this row to a master spreadsheet. However, I want to add a row if the number is not in column B. If the number exists then just update that row. Is this possible with script? I know your example is sheets within the same spreadsheet.... so mine is a little different.

    • @yagisanatode
      @yagisanatode  Рік тому

      Hi Michael. Yes is it possible,
      The closest I have tutorial-wise is this: yagisanatode.com/2019/02/13/google-apps-script-when-i-add-a-value-to-a-cell-in-a-selected-column-i-want-it-to-move-to-another-google-sheet/
      You might be able to modify it to your own needs.
      It might be worth having a chat with a developer to see what they can do to solve your specific problem.
      I'll keep your request in mind though and added to my tutorial list.

  • @nursahrum1129
    @nursahrum1129 Рік тому

    Thanks Yagi. can help me.... post coding in here please....

  • @moses5407
    @moses5407 8 місяців тому

    Can this be extended/modified such that the source sheet's script creates the destination sheet, reads its I'd, and uses that id for the destination I'd?

    • @yagisanatode
      @yagisanatode  8 місяців тому

      Absolutely. You could generate a new sheet tab in the existing Google Sheet workbook or create a new Google Sheet.
      developers.google.com/apps-script/reference/drive/file#makeCopy(String,Folder) developers.google.com/apps-script/reference/spreadsheet/spreadsheet#copy(String)

  • @buivancao6035
    @buivancao6035 2 роки тому

    Thank you. But i have a question that how to put one defined ID in the position of DestinationID. I want use 1 DestinationID for multiple sourceID when i publish the function. Tks.

    • @yagisanatode
      @yagisanatode  2 роки тому +1

      Sure, you could user an interator like a 'for' loop or forEach to iterate through the importRange() function each time changing the sourceID.

  • @ingewll
    @ingewll 2 роки тому +1

    Can I copy the column width and row hight to destination sheet too?

    • @yagisanatode
      @yagisanatode  2 роки тому

      Hi Inge. You sure can. You can use the getRowHeight() getColumnHeight() and setRowHeight() setColumnHeight() methods here.
      developers.google.com/apps-script/reference/spreadsheet/sheet?hl=en#setrowheightrowposition,-height
      You can find a similar example of this in action in this tutorial here:
      yagisanatode.com/2019/03/22/google-apps-script-maintain-row-heights-when-copying-and-pasting-data-in-google-sheets/

  • @kamalzdaz2395
    @kamalzdaz2395 2 роки тому +1

    How can ee do this import in append way...means i don't want to overwrite the data...everytime when I will run the script then data needs to copy paste in append way means the last row of that destination sheet..and later i will romove duplicate data via using the duplicate script functions

    • @kamalzdaz2395
      @kamalzdaz2395 2 роки тому

      any update

    • @yagisanatode
      @yagisanatode  2 роки тому

      Hi Kamalz, Apologies for the delay. I took a little time of a busy work schedule. Yes this tutorial is designed for those cases where you want to overwrite data in a range. You can use the SpreadsheetApp appendRow() method for adding individual rows of data to the bottom of the sheet. Likewise you can use the getLastRow() method to find the last row of the sheet and start your range from there. If you have a busy Google Sheet with lots of users you may also need to use LockService to prevent users from adding to cells simultaneously. I'll be covering these approaches in future videos.
      Here are some other tutorials is you have slightly different needs:
      - Google Apps Script: Get the last row of a data range when other columns have content like hidden formulas and check boxes [updated Dec 2021] - yagisanatode.com/2019/05/11/google-apps-script-get-the-last-row-of-a-data-range-when-other-columns-have-content-like-hidden-formulas-and-check-boxes/
      - Google Apps Script - When I add a value to a cell in a selected column, I want it to move to another Google Sheet [update Jan 2022] - yagisanatode.com/2019/02/13/google-apps-script-when-i-add-a-value-to-a-cell-in-a-selected-column-i-want-it-to-move-to-another-google-sheet/
      - Google Apps Script - Copy Selected Columns in One Sheet and Add Them To The Bottom of Different Selected Columns in Another - yagisanatode.com/2018/11/17/google-apps-script-copy-selected-columns-in-one-sheet-and-add-them-to-the-bottom-of-different-selected-columns-in-another/

  • @RensleyDaalHD
    @RensleyDaalHD Рік тому +1

    Very nice video. but i have 1 question you used "Sheet1!B2". but how can i define that using a Cell. For example i have multiple sheets. (Sheet1, Sheet2......and so on) but by using a Cell. and in that cell i type Sheet2. and it goes to Sheet2 B2 etc?

    • @yagisanatode
      @yagisanatode  Рік тому

      You might find this series useful: ua-cam.com/play/PLSDEbLgMgqvrwnVekQKlrx1Zyi1tUFsyY.html
      Particularly the third tutorial: ua-cam.com/video/AgwnbVM8-kw/v-deo.html

  • @IGLESIASVEGA
    @IGLESIASVEGA Рік тому +1

    would this work if the source sheet is an .xlsx file - that is stored in a google drive?

    • @yagisanatode
      @yagisanatode  Рік тому

      Not directly but Csaba Csonka has a pretty innovative workaround for this: github.com/cscsonka/Parsing-MS-Excel-file-with-Google-Apps-Script
      Buy him a coffee while you are there! 😉

  • @edenjobsheet9410
    @edenjobsheet9410 2 роки тому

    What's the best way to copy and paste the formatting as well?

    • @yagisanatode
      @yagisanatode  2 роки тому

      In this specific case of copying between different sheet you will also need to use formatting collectors like .getBackgroundColor() => setBackgroundColor(), and .getRichTextValues() => .setRichTextValues() is a pretty good catchall. developers.google.com/apps-script/reference/spreadsheet/range

  • @MathematicalSeries-be9wc
    @MathematicalSeries-be9wc 10 місяців тому

    My Friend,
    in Line 21. to Clear Specific Cell Ranges like B2 to G2 downwards, can I modify it to : destSheet.Clear (B2: G)
    or what command do i use?

    • @yagisanatode
      @yagisanatode  10 місяців тому +1

      You will need to get the range first using getRange("B2:G") on your `destSheet`. The auto suggestions will list a number of clear options like clear(), clearConditionalFormatRules(), clearContents(), clearFormats(), clearNotes()

    • @MathematicalSeries-be9wc
      @MathematicalSeries-be9wc 10 місяців тому

      @@yagisanatode . ok Great. Thanks alot

  • @rahmanpasha5314
    @rahmanpasha5314 2 роки тому

    Hi,
    I'm getting an error that's mentioned below.
    Exception: the parameters (number, number, number, null) don't match the method signature for SpreadsheetApp. Sheet. getRange.
    Please can someone help me out here.

    • @PaweCzech-ol4xz
      @PaweCzech-ol4xz Рік тому

      In last code line I used "lenght" not "length". Try checking out your gramar

  • @orakur8242
    @orakur8242 2 роки тому +1

    Hey ! That was deeply helpfull thaks lot ! 😊 Atm im stuck with and additonal step i would love to implement (since few hours, editing your script). I try to remplace the "destinationRangeStart" with some kind of "MySheet.getLastRow()+1" but i really don't know where i can implement it. Could you help ? ❤

    • @orakur8242
      @orakur8242 2 роки тому +1

      Cheers ! With some tryhard and a lot and hour i finally made it by myself ! Thanks both to this video and some of your website exemple. 🥳

    • @yagisanatode
      @yagisanatode  2 роки тому +1

      Great to hear. That's always more satisfying figuring it out your self. Nice work, Orakur!

    • @michaelhaj1
      @michaelhaj1 2 роки тому

      @@orakur8242 hello, could you please share the bits of the code that you needed to adjust? Looking exactly for this but I am stuck. Thank you!!

    • @michaelhaj1
      @michaelhaj1 2 роки тому

      edit: nope, does not work, resp. looks like I have to run the original code, then change it to the below and it works. If I run it in an empty file, it does not work. I AM CONFUSED!
      sorted it this way and seems to work
      // Get the full data range to paste into next empty row after start range.
      const destRange = destSheet.getRange(
      destStartRange.getNextDataCell(SpreadsheetApp.Direction.DOWN).getRow()+1,
      destStartRange.getColumn(),
      sourceVals.length,
      sourceVals[0].length

    • @bobthevegetables607
      @bobthevegetables607 2 роки тому

      ​@@michaelhaj1 seems my first comment was deleted due to the link of the pastebin ^^ share me a trash mail i send you what i have done. I have commented it a bit with what i remembered. 😊I think if you have followed this video you could easily understand what i have added and edit it for yours ! 😉

  • @afahruf90
    @afahruf90 2 роки тому

    How to add many rows data to existing sheet (data).. In a same googlesheet..

    • @yagisanatode
      @yagisanatode  2 роки тому

      Hi Awwal, you can find links to more ways of adding data to Google Sheets in the links in the description above. Hope this helps.

  • @everettpeschke286
    @everettpeschke286 2 роки тому +1

    Great video, but I can't seem to find the code for the video. It is exactly what I've been looking for. Can you point me to the download for the code. Thanks

    • @yagisanatode
      @yagisanatode  2 роки тому

      Hi Everett, you can find the code in the written tutorial. It's the second link in the description.

    • @everettpeschke286
      @everettpeschke286 2 роки тому

      @@yagisanatode sorry - it doesn't seem to download - All I get is a "function MyFunction()"

    • @yagisanatode
      @yagisanatode  2 роки тому

      @@everettpeschke286 The first link should be the starter sheet for you to follow along and write the code following the video. The next link is for the written tutorial. The full code is there if you get stuck along the way.

    • @everettpeschke286
      @everettpeschke286 2 роки тому

      @@yagisanatode OK thanks - I just typed it in from the video. Great work. You'll get a cup of coffee if I get it working...

    • @yagisanatode
      @yagisanatode  2 роки тому

      @@everettpeschke286 Awesome! Happy coding!

  • @MathematicalSeries-be9wc
    @MathematicalSeries-be9wc 10 місяців тому

    I have a Question: Great Video.
    My sourceRange"XYZ! A2: G" is only generating 1 value out of the multiple data in the source sheet
    what am I doing wrong?

    • @MathematicalSeries-be9wc
      @MathematicalSeries-be9wc 10 місяців тому

      Line 4 in the code is Returning only 1 cell data instead of a Range of data

    • @yagisanatode
      @yagisanatode  10 місяців тому +1

      Hmm are you using getValue() | setValue() or getValues() | setValues()?

    • @MathematicalSeries-be9wc
      @MathematicalSeries-be9wc 10 місяців тому

      ​@@yagisanatode, I feel like Giving you are Great Hug Right Now....That was exactly the Problem. it's working now with getValues(). 100% Appreciation to you Bro!! 🤪

  • @Bafa
    @Bafa Рік тому

    I am having an issue where it's copying the date and is minus one day. I've tried changing cell format and validating cells to make it quit. Been on it about an hour and I can find no earthly reason why it is subtracting one day from any date that is copied. Anyone run into this or have an idea?
    ***EDIT**
    Solved. The sheet itself, under settings, was set to a different time zone. Not sure how that happened, but once I made them match there was no more issue.

    • @yagisanatode
      @yagisanatode  Рік тому

      Hmm... is it precisely one day, do you know? If so this might suggest a calculation error.
      Alternatively sometimes timezones of your Spreadsheets can be different and even your Apps Script project. You can check by going to File > Settings in your source and destination sheets. In your apps script project go to Project Settings > General Settings.
      Hopefully this helps troubleshoot your issue.
      yagisanatode.com/2020/11/17/google-sheets-beginners-change-your-current-workbooks-timezone-date-currency-16/
      yagisanatode.com/2021/03/10/help-my-times-triggers-are-not-in-sync-how-to-update-your-google-apps-script-project-time-zone/

    • @Bafa
      @Bafa Рік тому +1

      @@yagisanatode Solved - Time zone was exactly it. Thanks for reply.

  • @timkumwenda
    @timkumwenda 2 роки тому

    This is quite helpful. How can i make the destination range starting point (in the code it's "Input Data!A1") to be a variable and to always be last row in the sheet name Input Data?
    function runsies() {
    importRange1(
    "4uyrjP5dfsdfaWm_LG09nRwkVFTMuRPK", //not real Id
    "Dataset1",
    "87mkpYvpR02oyOYvhhgJOptNFZjtESGEje25A", //not real Id
    "Input Data!A1"
    );
    }

    • @yagisanatode
      @yagisanatode  2 роки тому

      Hi Timothy, your best bet would be to do this inside the getRange() function once you get the spreadhseet. SpreadsheetApp.openById(--THE SPREADSHEETSHEET ID--).getSheetByName(--SHEET TAB NAME--).getLastRow().
      There are some situations where this will not be 100% successful however, you can check out this tutorial for more information: yagisanatode.com/2019/05/11/google-apps-script-get-the-last-row-of-a-data-range-when-other-columns-have-content-like-hidden-formulas-and-check-boxes/

  • @haohuynh464
    @haohuynh464 Рік тому

    It have problem wheb i have large value ## it run out of time litmit appscript and data not transfer finish

    • @yagisanatode
      @yagisanatode  Рік тому

      Roughly, what size range are you looking at?

  • @video2532
    @video2532 Рік тому +1

    Hi there,
    First of all: thank you so much for your videos! They are really really helpful! I just subscribed to your channel :)
    It has been days (and nights) and weeks since I have been trying to find a solution to my issue, but unfortunately I did not find anything around :(
    This is my situation: I have several sheets with a list of the events (date, time, event name, description...). I would like to create a script that imports the data of each sheet in one sheet (called Master Calendar). I need this one Master sheet to have the data imported from the three sheets in chronological order (sorted first by the date column, then the time column), and that updates onEdit, too, when someone makes a change on one of the three sheets.
    I know how to do it with a formula:
    =QUERY({IMPORTRANGE("id1","sheetName1!A1:D"); IMPORTRANGE("id2","sheetName2!A1:D"); IMPORTRANGE("id3","sheetName3!A1:D")}, "select * order by Col2 asc")'); ​ , but I need a script. I don't want any formulas on the sheet.
    I tried your solution, but it only imports from one sheet at a time.
    Even when I write:
    importRange( ... );
    importRange( ... );
    as you suggest, it only shows me the result from one sheet copied and not from the other sheets (because the functions overlap).
    Please, I know that you can help me out with that. I am still learning and I hope to learn from you as well.
    Again, THANK YOU!

    • @yagisanatode
      @yagisanatode  Рік тому

      You'll need to append the data. Take a look at some of the other tutorial links in the description, they should help guide you to what you need.

  • @bariyatlikita6767
    @bariyatlikita6767 2 роки тому

    ​ @Yagisanatode -Scott-
    Thanks so much Scott. I have a question though, I tried modifying the script to paste the data in the last row of my destination sheet using the getLastRow function but it returns an error.
    "Final_collated_analysis!A2" ---- the destination range
    const destStartRange = destinationSS.getRange(destinationrangeStart.getLastRow)
    destStartRange.getLastRow()
    Please help and let me know if you have a better idea
    Thanks in advance : )

    • @yagisanatode
      @yagisanatode  2 роки тому

      Hi Bariyal, have a look at the written tutorial in the link in the description, it might give you a better understanding on what is going on.
      In the example, the getRange() method takes 4 arguments, .getRange(start Row, start Col, row depth, col width) Notice that all these arguments are contained in braces "()"
      To apply a value to the last row try something like this:
      // Get the full data range to paste from start range.
      const destRange = destSheet.getRange(
      destStartRange.getLastRow(),
      destStartRange.getColumn(), // OR col 1 or for col A
      sourceVals.length,
      sourceVals[0].length
      );
      Hope this helps.

    • @bariyatlikita6767
      @bariyatlikita6767 2 роки тому

      @@yagisanatode Thanks, it really helped.

  • @PaweCzech-ol4xz
    @PaweCzech-ol4xz Рік тому

    Hi,
    I'm getting an error that's mentioned below.
    Exception: the parameters (number, number, number, null) don't match the method signature for SpreadsheetApp. Sheet. getRange.
    Help.

    • @PaweCzech-ol4xz
      @PaweCzech-ol4xz Рік тому +1

      Ok nevermind. In last code line I used "lenght" not "length" :D

    • @yagisanatode
      @yagisanatode  Рік тому

      "lenght" is my arch-nemesis.

  • @nessus85100
    @nessus85100 2 роки тому

    Hi Scot and thanks for this great script. I've been searching the internet for something like this for days. I've try to modify your script for my real working scenario and i got stuck. My question is... can this script to copy ONLY the range values from today's date and later?. If is helpful i can add formatted dates in row 1 in all columns in all the sleets in both spreadsheets.

    • @yagisanatode
      @yagisanatode  2 роки тому

      After collecting your data try using a loop or the JS .filter() method to iterate through your values in your range to find dates greater than or equal to what you need.