{"id":6022,"date":"2013-10-23T21:52:43","date_gmt":"2013-10-23T18:52:43","guid":{"rendered":"http:\/\/railsware.com\/blog\/?p=6022"},"modified":"2021-08-12T16:52:20","modified_gmt":"2021-08-12T13:52:20","slug":"google-spreadsheet-scripts-useful-functions-copying-with-custom-conditions","status":"publish","type":"post","link":"https:\/\/railsware.com\/blog\/google-spreadsheet-scripts-useful-functions-copying-with-custom-conditions\/","title":{"rendered":"Google spreadsheet scripts: useful functions. Copying with custom conditions"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Problem<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">You need to copy a bunch of data from one spreadsheet to another with the following custom conditions: limited range and filters on different cell values. This is a very boring task to perform manually, but the good news is that it can be automated.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Solution<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">In order to solve the task, I&#8217;ve created <i>CopyDataFromSStoAnotherSSWithComplexFilter<\/i> function. It receives the following parameters:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>source spreadsheet id<\/li><li>source sheet name<\/li><li>complex filter &#8211; limit data with combination of simpler filters<\/li><li>limit range of data to be processed<\/li><li>target spreadsheet id<\/li><li>target sheet name<\/li><li>target cell position &#8211; initial place for copied data<\/li><li>arrangement method &#8211; insert as new rows or replace existing cell values<\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Let\u2019s try this function on the example we have available.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Working example<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Open <a title=\"Useful Google Scripts Example 1\" href=\"http:\/\/l.rw.rw\/example\" target=\"_blank\" rel=\"noopener noreferrer\">example spreadsheet<\/a> and wait for 5 seconds for these menus to appear:<a href=\"https:\/\/railsware.com\/blog\/wp-content\/uploads\/2013\/10\/2013-10-21_1311.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-6026 size-full\" src=\"https:\/\/railsware.com\/blog\/wp-content\/uploads\/2013\/10\/2013-10-21_1311.png\" alt=\"2013-10-21_1311\" width=\"735\" height=\"270\"><\/a><br>Our example has 3 sheets:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>config_data &#8211; keeps all settings for our example<\/li><li>source_data &#8211; data which will be copied<\/li><li>target_data &#8211; contains result of our example execution<\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">To copy data use <i>&#8220;Copy data with config_data settings&#8221;<\/i> menu item from <i>&#8220;Run Functions Examples&#8221;<\/i>.<br>You can change settings in B column of <i>config_data<\/i> sheet and see how it affects <i>target_data<\/i> sheet. But in order to be able to customize them properly, let&#8217;s discuss how to cook filter conditions.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Complex Filter<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Complex filter combines ordinary filters with AND, OR operators. Ordinary filter is an array &#8211; <i>[column, filteringValue, filteringCondition]<\/i>. Where <i>column<\/i> &#8211; number of column (starts from 0), which is compared to <i>filteringValue<\/i> with <i>filteringCondition<\/i> (\u2018==\u2019, \u2018!=\u2019, \u2018&gt;\u2019, \u2018&lt;\u2019, \u2018&gt;=\u2019, \u2018=&lt;\u2019, \u2018contains\u2019). For example:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">var ordinaryFilter = [0,\u201dsolar\u201d, \u201ccontains\u201d];<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This condition leaves only rows containing &#8220;solar&#8221; word in A column (0 index).<br>Array of ordinary filters is combined with AND operators:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">var condition1withAND = [ordinaryFilter1, ordinaryFilter2, ordinaryFilter3];<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Array of different conditionswithAND is combined with OR operator:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">var complexfilter = [condition1withAND, condition2withAND, condition3withAND]<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">It means that returned data will meet <i>condition1withAND<\/i> OR <i>condition2withAND<\/i> OR <i>condition3withAND<\/i>.<br><a href=\"https:\/\/railsware.com\/blog\/wp-content\/uploads\/2013\/10\/2013-10-21_1744.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-6025 size-full\" src=\"https:\/\/railsware.com\/blog\/wp-content\/uploads\/2013\/10\/2013-10-21_1744.png\" alt=\"2013-10-21_1744\" width=\"638\" height=\"298\"><\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Thus, we can build any complex condition. And there is another powerful option &#8211; limit source data by range.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Source Data Range Limit<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Next array limits source data by range:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">var sourceDataRangeLimit = [startRow, startColumn, numRows, numColumns];<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Currently we support only one range limit.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Two ways to copy prepared data to the target sheet<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Filtered and limited data can be inserted (default):<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">var isReplace = false;<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">or replaced:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">var isReplace = true;<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">For inserting, bunch of empty rows is created starting from specified target position and data is copied there.<br>For replacing, keep in mind that existing data will be overwritten.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">We&#8217;ve described all the key points of our example and <a title=\"Useful Google Scripts Example 1\" href=\"http:\/\/l.rw.rw\/example\" target=\"_blank\" rel=\"noopener noreferrer\">you can start playing with it<\/a>. In the next post I&#8217;m going to describe <i>DeleteByRangeWithComplexFilter<\/i> function.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Related Posts<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li><a title=\"Intro to Google Scripts\" href=\"http:\/\/l.rw.rw\/gscripts\" target=\"_blank\" rel=\"noopener noreferrer\">Intro to Google Application Scripts (GAS)<\/a><\/li><li><a title=\"Useful Triggers in Google Scripts\" href=\"http:\/\/l.rw.rw\/gscripts2\" target=\"_blank\" rel=\"noopener noreferrer\">Useful Triggers in Google Application Scripts<\/a><\/li><\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Problem You need to copy a bunch of data from one spreadsheet to another with the following custom conditions: limited range and filters on different cell values. This is a very boring task to perform manually, but the good news is that it can be automated. Solution In order to solve the task, I&#8217;ve created&#8230;<\/p>\n","protected":false},"author":54,"featured_media":9455,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"inline_featured_image":false,"footnotes":""},"categories":[3],"tags":[],"coauthors":["Oleg Shaydenko"],"class_list":["post-6022","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-development"],"acf":[],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 4.9.9 - aioseo.com -->\n\t<meta name=\"description\" content=\"Problem You need to copy a bunch of data from one spreadsheet to another with the following custom conditions: limited range and filters on different cell values. This is a very boring task to perform manually, but the good news is that it can be automated. Solution In order to solve the task, I&#039;ve created\" \/>\n\t<meta name=\"robots\" content=\"max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n\t<meta name=\"author\" content=\"Oleg Shaydenko\"\/>\n\t<link rel=\"canonical\" href=\"https:\/\/railsware.com\/blog\/google-spreadsheet-scripts-useful-functions-copying-with-custom-conditions\/\" \/>\n\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 4.9.9\" \/>\n\t\t<meta property=\"og:locale\" content=\"en_US\" \/>\n\t\t<meta property=\"og:site_name\" content=\"| Blog on Engineering, Product Management, Transparency, Culture and many more...\" \/>\n\t\t<meta property=\"og:type\" content=\"article\" \/>\n\t\t<meta property=\"og:title\" content=\"Google spreadsheet scripts: useful functions. Copying with custom conditions | Railsware Blog\" \/>\n\t\t<meta property=\"og:description\" content=\"Problem You need to copy a bunch of data from one spreadsheet to another with the following custom conditions: limited range and filters on different cell values. This is a very boring task to perform manually, but the good news is that it can be automated. Solution In order to solve the task, I&#039;ve created\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/railsware.com\/blog\/google-spreadsheet-scripts-useful-functions-copying-with-custom-conditions\/\" \/>\n\t\t<meta property=\"og:image\" content=\"https:\/\/railsware.com\/blog\/wp-content\/uploads\/2017\/12\/Google-spreadsheet-scripts.png\" \/>\n\t\t<meta property=\"og:image:secure_url\" content=\"https:\/\/railsware.com\/blog\/wp-content\/uploads\/2017\/12\/Google-spreadsheet-scripts.png\" \/>\n\t\t<meta property=\"og:image:width\" content=\"360\" \/>\n\t\t<meta property=\"og:image:height\" content=\"360\" \/>\n\t\t<meta property=\"article:published_time\" content=\"2013-10-23T18:52:43+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2021-08-12T13:52:20+00:00\" \/>\n\t\t<script type=\"application\/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/railsware.com\\\/blog\\\/google-spreadsheet-scripts-useful-functions-copying-with-custom-conditions\\\/#article\",\"name\":\"Google spreadsheet scripts: useful functions. Copying with custom conditions | Railsware Blog\",\"headline\":\"Google spreadsheet scripts: useful functions. Copying with custom conditions\",\"author\":{\"@id\":\"https:\\\/\\\/railsware.com\\\/blog\\\/author\\\/oleg-shaydenko\\\/#author\"},\"publisher\":{\"@id\":\"https:\\\/\\\/railsware.com\\\/blog\\\/#organization\"},\"image\":{\"@type\":\"ImageObject\",\"url\":\"https:\\\/\\\/railsware.com\\\/blog\\\/wp-content\\\/uploads\\\/2017\\\/12\\\/Google-spreadsheet-scripts.png\",\"width\":360,\"height\":360,\"caption\":\"Google spreadsheet scripts\"},\"datePublished\":\"2013-10-23T21:52:43+03:00\",\"dateModified\":\"2021-08-12T16:52:20+03:00\",\"inLanguage\":\"en-US\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/railsware.com\\\/blog\\\/google-spreadsheet-scripts-useful-functions-copying-with-custom-conditions\\\/#webpage\"},\"isPartOf\":{\"@id\":\"https:\\\/\\\/railsware.com\\\/blog\\\/google-spreadsheet-scripts-useful-functions-copying-with-custom-conditions\\\/#webpage\"},\"articleSection\":\"Engineering\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/railsware.com\\\/blog\\\/google-spreadsheet-scripts-useful-functions-copying-with-custom-conditions\\\/#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/railsware.com\\\/blog#listItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/railsware.com\\\/blog\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/railsware.com\\\/blog\\\/category\\\/development\\\/#listItem\",\"name\":\"Engineering\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/railsware.com\\\/blog\\\/category\\\/development\\\/#listItem\",\"position\":2,\"name\":\"Engineering\",\"item\":\"https:\\\/\\\/railsware.com\\\/blog\\\/category\\\/development\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/railsware.com\\\/blog\\\/google-spreadsheet-scripts-useful-functions-copying-with-custom-conditions\\\/#listItem\",\"name\":\"Google spreadsheet scripts: useful functions. Copying with custom conditions\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/railsware.com\\\/blog#listItem\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/railsware.com\\\/blog\\\/google-spreadsheet-scripts-useful-functions-copying-with-custom-conditions\\\/#listItem\",\"position\":3,\"name\":\"Google spreadsheet scripts: useful functions. Copying with custom conditions\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/railsware.com\\\/blog\\\/category\\\/development\\\/#listItem\",\"name\":\"Engineering\"}}]},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/railsware.com\\\/blog\\\/#organization\",\"description\":\"Blog on Engineering, Product Management, Transparency, Culture and many more...\",\"url\":\"https:\\\/\\\/railsware.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https:\\\/\\\/railsware.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/11\\\/Logo-circle.png\",\"@id\":\"https:\\\/\\\/railsware.com\\\/blog\\\/google-spreadsheet-scripts-useful-functions-copying-with-custom-conditions\\\/#organizationLogo\",\"width\":3137,\"height\":1054,\"caption\":\"Railsware logo\"},\"image\":{\"@id\":\"https:\\\/\\\/railsware.com\\\/blog\\\/google-spreadsheet-scripts-useful-functions-copying-with-custom-conditions\\\/#organizationLogo\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/railsware.com\\\/blog\\\/author\\\/oleg-shaydenko\\\/#author\",\"url\":\"https:\\\/\\\/railsware.com\\\/blog\\\/author\\\/oleg-shaydenko\\\/\",\"name\":\"Oleg Shaydenko\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/railsware.com\\\/blog\\\/google-spreadsheet-scripts-useful-functions-copying-with-custom-conditions\\\/#authorImage\",\"url\":\"https:\\\/\\\/railsware.com\\\/blog\\\/wp-content\\\/uploads\\\/2021\\\/06\\\/author-image-default-96x96.jpg\",\"width\":96,\"height\":96,\"caption\":\"Oleg Shaydenko\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/railsware.com\\\/blog\\\/google-spreadsheet-scripts-useful-functions-copying-with-custom-conditions\\\/#webpage\",\"url\":\"https:\\\/\\\/railsware.com\\\/blog\\\/google-spreadsheet-scripts-useful-functions-copying-with-custom-conditions\\\/\",\"name\":\"Google spreadsheet scripts: useful functions. Copying with custom conditions | Railsware Blog\",\"description\":\"Problem You need to copy a bunch of data from one spreadsheet to another with the following custom conditions: limited range and filters on different cell values. This is a very boring task to perform manually, but the good news is that it can be automated. Solution In order to solve the task, I've created\",\"inLanguage\":\"en-US\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/railsware.com\\\/blog\\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/railsware.com\\\/blog\\\/google-spreadsheet-scripts-useful-functions-copying-with-custom-conditions\\\/#breadcrumblist\"},\"author\":{\"@id\":\"https:\\\/\\\/railsware.com\\\/blog\\\/author\\\/oleg-shaydenko\\\/#author\"},\"creator\":{\"@id\":\"https:\\\/\\\/railsware.com\\\/blog\\\/author\\\/oleg-shaydenko\\\/#author\"},\"image\":{\"@type\":\"ImageObject\",\"url\":\"https:\\\/\\\/railsware.com\\\/blog\\\/wp-content\\\/uploads\\\/2017\\\/12\\\/Google-spreadsheet-scripts.png\",\"@id\":\"https:\\\/\\\/railsware.com\\\/blog\\\/google-spreadsheet-scripts-useful-functions-copying-with-custom-conditions\\\/#mainImage\",\"width\":360,\"height\":360,\"caption\":\"Google spreadsheet scripts\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/railsware.com\\\/blog\\\/google-spreadsheet-scripts-useful-functions-copying-with-custom-conditions\\\/#mainImage\"},\"datePublished\":\"2013-10-23T21:52:43+03:00\",\"dateModified\":\"2021-08-12T16:52:20+03:00\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/railsware.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/railsware.com\\\/blog\\\/\",\"description\":\"Blog on Engineering, Product Management, Transparency, Culture and many more...\",\"inLanguage\":\"en-US\",\"publisher\":{\"@id\":\"https:\\\/\\\/railsware.com\\\/blog\\\/#organization\"}}]}\n\t\t<\/script>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"Google spreadsheet scripts: useful functions. Copying with custom conditions | Railsware Blog","description":"Problem You need to copy a bunch of data from one spreadsheet to another with the following custom conditions: limited range and filters on different cell values. This is a very boring task to perform manually, but the good news is that it can be automated. Solution In order to solve the task, I've created","canonical_url":"https:\/\/railsware.com\/blog\/google-spreadsheet-scripts-useful-functions-copying-with-custom-conditions\/","robots":"max-snippet:-1, max-image-preview:large, max-video-preview:-1","keywords":"","webmasterTools":{"miscellaneous":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/railsware.com\/blog\/google-spreadsheet-scripts-useful-functions-copying-with-custom-conditions\/#article","name":"Google spreadsheet scripts: useful functions. Copying with custom conditions | Railsware Blog","headline":"Google spreadsheet scripts: useful functions. Copying with custom conditions","author":{"@id":"https:\/\/railsware.com\/blog\/author\/oleg-shaydenko\/#author"},"publisher":{"@id":"https:\/\/railsware.com\/blog\/#organization"},"image":{"@type":"ImageObject","url":"https:\/\/railsware.com\/blog\/wp-content\/uploads\/2017\/12\/Google-spreadsheet-scripts.png","width":360,"height":360,"caption":"Google spreadsheet scripts"},"datePublished":"2013-10-23T21:52:43+03:00","dateModified":"2021-08-12T16:52:20+03:00","inLanguage":"en-US","mainEntityOfPage":{"@id":"https:\/\/railsware.com\/blog\/google-spreadsheet-scripts-useful-functions-copying-with-custom-conditions\/#webpage"},"isPartOf":{"@id":"https:\/\/railsware.com\/blog\/google-spreadsheet-scripts-useful-functions-copying-with-custom-conditions\/#webpage"},"articleSection":"Engineering"},{"@type":"BreadcrumbList","@id":"https:\/\/railsware.com\/blog\/google-spreadsheet-scripts-useful-functions-copying-with-custom-conditions\/#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"https:\/\/railsware.com\/blog#listItem","position":1,"name":"Home","item":"https:\/\/railsware.com\/blog","nextItem":{"@type":"ListItem","@id":"https:\/\/railsware.com\/blog\/category\/development\/#listItem","name":"Engineering"}},{"@type":"ListItem","@id":"https:\/\/railsware.com\/blog\/category\/development\/#listItem","position":2,"name":"Engineering","item":"https:\/\/railsware.com\/blog\/category\/development\/","nextItem":{"@type":"ListItem","@id":"https:\/\/railsware.com\/blog\/google-spreadsheet-scripts-useful-functions-copying-with-custom-conditions\/#listItem","name":"Google spreadsheet scripts: useful functions. Copying with custom conditions"},"previousItem":{"@type":"ListItem","@id":"https:\/\/railsware.com\/blog#listItem","name":"Home"}},{"@type":"ListItem","@id":"https:\/\/railsware.com\/blog\/google-spreadsheet-scripts-useful-functions-copying-with-custom-conditions\/#listItem","position":3,"name":"Google spreadsheet scripts: useful functions. Copying with custom conditions","previousItem":{"@type":"ListItem","@id":"https:\/\/railsware.com\/blog\/category\/development\/#listItem","name":"Engineering"}}]},{"@type":"Organization","@id":"https:\/\/railsware.com\/blog\/#organization","description":"Blog on Engineering, Product Management, Transparency, Culture and many more...","url":"https:\/\/railsware.com\/blog\/","logo":{"@type":"ImageObject","url":"https:\/\/railsware.com\/blog\/wp-content\/uploads\/2020\/11\/Logo-circle.png","@id":"https:\/\/railsware.com\/blog\/google-spreadsheet-scripts-useful-functions-copying-with-custom-conditions\/#organizationLogo","width":3137,"height":1054,"caption":"Railsware logo"},"image":{"@id":"https:\/\/railsware.com\/blog\/google-spreadsheet-scripts-useful-functions-copying-with-custom-conditions\/#organizationLogo"}},{"@type":"Person","@id":"https:\/\/railsware.com\/blog\/author\/oleg-shaydenko\/#author","url":"https:\/\/railsware.com\/blog\/author\/oleg-shaydenko\/","name":"Oleg Shaydenko","image":{"@type":"ImageObject","@id":"https:\/\/railsware.com\/blog\/google-spreadsheet-scripts-useful-functions-copying-with-custom-conditions\/#authorImage","url":"https:\/\/railsware.com\/blog\/wp-content\/uploads\/2021\/06\/author-image-default-96x96.jpg","width":96,"height":96,"caption":"Oleg Shaydenko"}},{"@type":"WebPage","@id":"https:\/\/railsware.com\/blog\/google-spreadsheet-scripts-useful-functions-copying-with-custom-conditions\/#webpage","url":"https:\/\/railsware.com\/blog\/google-spreadsheet-scripts-useful-functions-copying-with-custom-conditions\/","name":"Google spreadsheet scripts: useful functions. Copying with custom conditions | Railsware Blog","description":"Problem You need to copy a bunch of data from one spreadsheet to another with the following custom conditions: limited range and filters on different cell values. This is a very boring task to perform manually, but the good news is that it can be automated. Solution In order to solve the task, I've created","inLanguage":"en-US","isPartOf":{"@id":"https:\/\/railsware.com\/blog\/#website"},"breadcrumb":{"@id":"https:\/\/railsware.com\/blog\/google-spreadsheet-scripts-useful-functions-copying-with-custom-conditions\/#breadcrumblist"},"author":{"@id":"https:\/\/railsware.com\/blog\/author\/oleg-shaydenko\/#author"},"creator":{"@id":"https:\/\/railsware.com\/blog\/author\/oleg-shaydenko\/#author"},"image":{"@type":"ImageObject","url":"https:\/\/railsware.com\/blog\/wp-content\/uploads\/2017\/12\/Google-spreadsheet-scripts.png","@id":"https:\/\/railsware.com\/blog\/google-spreadsheet-scripts-useful-functions-copying-with-custom-conditions\/#mainImage","width":360,"height":360,"caption":"Google spreadsheet scripts"},"primaryImageOfPage":{"@id":"https:\/\/railsware.com\/blog\/google-spreadsheet-scripts-useful-functions-copying-with-custom-conditions\/#mainImage"},"datePublished":"2013-10-23T21:52:43+03:00","dateModified":"2021-08-12T16:52:20+03:00"},{"@type":"WebSite","@id":"https:\/\/railsware.com\/blog\/#website","url":"https:\/\/railsware.com\/blog\/","description":"Blog on Engineering, Product Management, Transparency, Culture and many more...","inLanguage":"en-US","publisher":{"@id":"https:\/\/railsware.com\/blog\/#organization"}}]},"og:locale":"en_US","og:site_name":"| Blog on Engineering, Product Management, Transparency, Culture and many more...","og:type":"article","og:title":"Google spreadsheet scripts: useful functions. Copying with custom conditions | Railsware Blog","og:description":"Problem You need to copy a bunch of data from one spreadsheet to another with the following custom conditions: limited range and filters on different cell values. This is a very boring task to perform manually, but the good news is that it can be automated. Solution In order to solve the task, I've created","og:url":"https:\/\/railsware.com\/blog\/google-spreadsheet-scripts-useful-functions-copying-with-custom-conditions\/","og:image":"https:\/\/railsware.com\/blog\/wp-content\/uploads\/2017\/12\/Google-spreadsheet-scripts.png","og:image:secure_url":"https:\/\/railsware.com\/blog\/wp-content\/uploads\/2017\/12\/Google-spreadsheet-scripts.png","og:image:width":360,"og:image:height":360,"article:published_time":"2013-10-23T18:52:43+00:00","article:modified_time":"2021-08-12T13:52:20+00:00"},"aioseo_meta_data":{"post_id":"6022","title":null,"description":null,"keywords":[],"keyphrases":{"focus":[],"additional":[]},"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":"","og_custom_url":null,"og_article_section":null,"og_article_tags":[],"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":{"id":"aioseo-article-6385f5b18f31f","slug":"article","graphName":"Article","label":"Article","properties":{"type":"BlogPosting","name":"#post_title","headline":"#post_title","description":"#post_excerpt","image":"","keywords":"","author":{"name":"#author_name","url":"#author_url"},"dates":{"include":true,"datePublished":"","dateModified":""}}},"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"Article","isEnabled":true},"graphs":[]},"schema_type":"default","schema_type_options":"{\"article\":{\"articleType\":\"BlogPosting\"},\"course\":{\"name\":\"\",\"description\":\"\",\"provider\":\"\"},\"faq\":{\"pages\":[]},\"product\":{\"reviews\":[]},\"recipe\":{\"ingredients\":[],\"instructions\":[],\"keywords\":[]},\"software\":{\"reviews\":[],\"operatingSystems\":[]},\"webPage\":{\"webPageType\":\"WebPage\"}}","pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":"-1","robots_max_videopreview":"-1","robots_max_imagepreview":"large","priority":null,"frequency":"default","location":null,"local_seo":{"locations":{"business":{"name":"","businessType":"","image":"","areaServed":"","urls":{"website":"","aboutPage":"","contactPage":""},"address":{"streetLine1":"","streetLine2":"","zipCode":"","city":"","state":"","country":"","addressFormat":"#streetLineOne\n#streetLineTwo\n#city, #state #zipCode"},"contact":{"email":"","phone":"","phoneFormatted":"","fax":"","faxFormatted":""},"ids":{"vat":"","tax":"","chamberOfCommerce":""},"payment":{"priceRange":"","currenciesAccepted":"","methods":""}}},"openingHours":{"useDefaults":true,"show":true,"alwaysOpen":false,"use24hFormat":false,"timezone":"","labels":{"closed":"","alwaysOpen":""},"days":{"monday":{"open24h":false,"closed":false,"openTime":"09:00","closeTime":"17:00"},"tuesday":{"open24h":false,"closed":false,"openTime":"09:00","closeTime":"17:00"},"wednesday":{"open24h":false,"closed":false,"openTime":"09:00","closeTime":"17:00"},"thursday":{"open24h":false,"closed":false,"openTime":"09:00","closeTime":"17:00"},"friday":{"open24h":false,"closed":false,"openTime":"09:00","closeTime":"17:00"},"saturday":{"open24h":false,"closed":false,"openTime":"09:00","closeTime":"17:00"},"sunday":{"open24h":false,"closed":false,"openTime":"09:00","closeTime":"17:00"}}}},"breadcrumb_settings":null,"limit_modified_date":false,"ai":null,"created":"2021-01-04 12:44:29","updated":"2025-09-26 11:19:39","seo_analyzer_scan_date":null},"aioseo_breadcrumb":"<div class=\"aioseo-breadcrumbs\"><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/railsware.com\/blog\" title=\"Home\">Home<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/railsware.com\/blog\/category\/development\/\" title=\"Engineering\">Engineering<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\tGoogle spreadsheet scripts: useful functions. Copying with custom conditions\n\t\t<\/span><\/div>","aioseo_breadcrumb_json":[{"label":"Home","link":"https:\/\/railsware.com\/blog"},{"label":"Engineering","link":"https:\/\/railsware.com\/blog\/category\/development\/"},{"label":"Google spreadsheet scripts: useful functions. Copying with custom conditions","link":"https:\/\/railsware.com\/blog\/google-spreadsheet-scripts-useful-functions-copying-with-custom-conditions\/"}],"categories_data":[{"name":"Engineering","link":"https:\/\/railsware.com\/blog?category=development"}],"post_thumbnails":"https:\/\/railsware.com\/blog\/wp-content\/uploads\/2017\/12\/Google-spreadsheet-scripts.png","article_background":"","amp_enabled":true,"_links":{"self":[{"href":"https:\/\/railsware.com\/blog\/wp-json\/wp\/v2\/posts\/6022","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/railsware.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/railsware.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/railsware.com\/blog\/wp-json\/wp\/v2\/users\/54"}],"replies":[{"embeddable":true,"href":"https:\/\/railsware.com\/blog\/wp-json\/wp\/v2\/comments?post=6022"}],"version-history":[{"count":114,"href":"https:\/\/railsware.com\/blog\/wp-json\/wp\/v2\/posts\/6022\/revisions"}],"predecessor-version":[{"id":13983,"href":"https:\/\/railsware.com\/blog\/wp-json\/wp\/v2\/posts\/6022\/revisions\/13983"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/railsware.com\/blog\/wp-json\/wp\/v2\/media\/9455"}],"wp:attachment":[{"href":"https:\/\/railsware.com\/blog\/wp-json\/wp\/v2\/media?parent=6022"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/railsware.com\/blog\/wp-json\/wp\/v2\/categories?post=6022"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/railsware.com\/blog\/wp-json\/wp\/v2\/tags?post=6022"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/railsware.com\/blog\/wp-json\/wp\/v2\/coauthors?post=6022"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}