{"id":254707,"date":"2017-11-29T15:00:28","date_gmt":"2017-11-29T14:00:28","guid":{"rendered":"https:\/\/blog.sheetgo.com\/?p=7434"},"modified":"2017-11-29T15:00:28","modified_gmt":"2017-11-29T14:00:28","slug":"creer-des-macros-dans-google-sheets","status":"publish","type":"post","link":"https:\/\/www.sheetgo.com\/es\/blog\/google-sheets-features\/create-macros-in-google-sheets\/","title":{"rendered":"\u00bfC\u00f3mo se crean macros en Google Sheets?"},"content":{"rendered":"\n[et_pb_section fb_built=&#8221;1&#8243; admin_label=&#8221;section&#8221; module_class=&#8221;sheetgo-post&#8221; _builder_version=&#8221;4.16&#8243; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;][et_pb_row admin_label=&#8221;row&#8221; _builder_version=&#8221;4.16&#8243; background_size=&#8221;initial&#8221; background_position=&#8221;top_left&#8221; background_repeat=&#8221;repeat&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;][et_pb_column type=&#8221;4_4&#8243; _builder_version=&#8221;4.16&#8243; custom_padding=&#8221;|||&#8221; global_colors_info=&#8221;{}&#8221; custom_padding__hover=&#8221;|||&#8221; theme_builder_area=&#8221;post_content&#8221;][et_pb_text _builder_version=&#8221;4.16&#8243; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;]<p>We most commonly use Google Sheets to store data and share it with others. Among other things it also lets us manipulate and analyze data, resulting in accordingly establishing trends etc. For a regular user, the tasks can get repetitive and time-consuming leading to error-prone. With the help of formulas, we can automate things to a great extent. But with macros (Google App Scripts) we can accomplish much more. In this article, we explain how to<span>\u00a0<\/span><em><strong>create macro in Google Sheets.<\/strong><\/em><\/p>[\/et_pb_text][et_pb_text _builder_version=&#8221;4.16&#8243; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;]<h3>Why create macros in Google Sheets?<\/h3>\n<p>Let us consider an example. A sales manager looks at a sales data sheet that is auto-populated with the latest raw information every day. Before he begins his work for the day, he needs to generate a report from this raw data in a pre-defined format. This task is accomplished with the exact same manual steps, and therefore it is highly repetitive in nature. Fortunately for him, he can automate the process and execute it in a matter of seconds. While previously he was taking much more to achieve the same output.<\/p>\n<p>We will use an extremely simple example to show how to create macros in Google Sheets. Because an advanced example is beyond the scope of this article. We recommend you going through<span>\u00a0<\/span><a href=\"https:\/\/developers.google.com\/apps-script\/articles\/tutorials\" target=\"_blank\" rel=\"noopener noreferrer\">this link<\/a><span>\u00a0<\/span>to learn the advanced concepts. The program we are going to write, for the purposes of demonstration in this article, does the following:<\/p>\n<ul>\n<li>Inserts a value \u201cHello world!\u201d in the cell A1.<\/li>\n<li>Changes the font to \u2018Calibri\u2019.<\/li>\n<li>Changes the font size in cell A1 to 14.<\/li>\n<li>Fills the cell A1 with yellow color.<\/li>\n<\/ul>\n<p>In order for us to get there, we need to navigate to<span>\u00a0<\/span><strong>Tools &gt; Script editor<\/strong>.<\/p>\n<p><strong>Example<\/strong><\/p>[\/et_pb_text][et_pb_image src=&#8221;https:\/\/static.sheetgo.com\/wp-content\/uploads\/2017\/11\/macros1.png&#8221; alt=&#8221;Navigation to Script Editor in Google Sheets&#8221; title_text=&#8221;script-editor&#8221; align=&#8221;center&#8221; module_class=&#8221;sheetgo-post-no-shadow-img&#8221; _builder_version=&#8221;4.16&#8243; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;][\/et_pb_image][et_pb_text _builder_version=&#8221;4.16&#8243; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;]<p>On doing that, it will provide us with a workspace where we can write and execute our program in a separate tab. On the<span>\u00a0<\/span><strong>Script editor<\/strong><span>\u00a0<\/span>window, we write the code as shown in the snapshot below. Before we\u00a0click on the<span>\u00a0<\/span><strong>Run<\/strong><span>\u00a0<\/span>button, we may want to<span>\u00a0<\/span><strong>Save<\/strong><span>\u00a0<\/span>it using the floppy disk icon.<\/p>\n<p><strong>Example<\/strong><\/p>[\/et_pb_text][et_pb_image src=&#8221;https:\/\/static.sheetgo.com\/wp-content\/uploads\/2017\/11\/macros2.png&#8221; alt=&#8221;Create Macro in Google Sheets&#8221; title_text=&#8221;create-macro&#8221; align=&#8221;center&#8221; module_class=&#8221;sheetgo-post-no-shadow-img&#8221; _builder_version=&#8221;4.16&#8243; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;][\/et_pb_image][et_pb_text _builder_version=&#8221;4.16&#8243; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;]<p>When we try to execute this program, it might ask us to authenticate for the very first time. Here\u2019s the result after the program finished its execution.<\/p>\n<p><strong>Example<\/strong><\/p>[\/et_pb_text][et_pb_image src=&#8221;https:\/\/static.sheetgo.com\/wp-content\/uploads\/2017\/11\/macros3.png&#8221; alt=&#8221;Create Macro in Google Sheets: Yellow Highlighted Hello World text in A Cell&#8221; title_text=&#8221;macro-result&#8221; align=&#8221;center&#8221; module_class=&#8221;sheetgo-post-no-shadow-img&#8221; _builder_version=&#8221;4.16&#8243; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;][\/et_pb_image][et_pb_text _builder_version=&#8221;4.16&#8243; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;]<h4>Conclusion<\/h4>\n<p>That was a fairly simple example that explains how to create macros in Google Sheets. However, the real-time applications can get very complex that usually simplifies a lot of stuff, which otherwise would have been difficult to achieve.<\/p>[\/et_pb_text][et_pb_text _builder_version=&#8221;4.16&#8243; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;]<h4>Advantages<\/h4>\n<p>The Google Apps script is very similar to Office VBA. But in comparison, Google Apps script offers much more benefits than the traditional VBA does.<\/p>\n<ol>\n<li>VBA runs on a client machine. Whereas\u00a0Google script runs on the cloud taking its reach and scale are much higher and more flexible. One can even build web-based applications using the Google script. But we can\u2019t achieve that with VBA, that at the most can integrate with web applications using an API.<\/li>\n<li>We can build user interfaces using both VBA and Google script. The former is constrained when it comes to design (we can only build user forms). But with the latter, we can also leverage the technologies such as HTML, CSS, and Javascript.<\/li>\n<li>The list of data types in VBA is limited, as it is still relying on a relatively older technology. While Google script is based on Javascript, which is one of the core web technologies. Therefore we can bank upon its object-oriented elements, flexible data structures, and numerous utilities and build upon that.<\/li>\n<\/ol>\n<p>Feel free to read through the following blog post to see what<span>\u00a0<\/span><a href=\"https:\/\/www.sheetgo.com\/blog\/spreadsheets-tips\/10-tips-tricks-maximize-google-sheets\/\" target=\"_blank\" rel=\"noopener noreferrer\">10 tips and tricks<\/a><span>\u00a0<\/span>we listed for you to maximize the results in Google Sheets!<\/p>[\/et_pb_text][\/et_pb_column][\/et_pb_row][\/et_pb_section]\n","protected":false},"excerpt":{"rendered":"<p>We most commonly use Google Sheets to store data and share it with others. Among other things it also lets us manipulate and analyze data, resulting in accordingly establishing trends etc. For a regular user, the tasks can get repetitive and time-consuming leading to error-prone. With the help of formulas, we can automate things to [&hellip;]<\/p>\n","protected":false},"author":40,"featured_media":254716,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_et_pb_use_builder":"on","_et_pb_old_content":"We most commonly use Google Sheets to store data and share it with others. Among other things it also lets us manipulate and analyze data, resulting in accordingly establishing trends etc. For a regular user, the tasks can get repetitive and time-consuming leading to error-prone. With the help of formulas, we can automate things to a great extent. But with macros (Google App Scripts) we can accomplish much more. In this article, we explain how to create macros in Google Sheets.\n<h3>Why create macros in Google Sheets?<\/h3>\nLet us consider an example. A sales manager looks at a sales data sheet that is auto-populated with the latest raw information every day. Before he begins his work for the day, he needs to generate a report from this raw data in a pre-defined format. This task is accomplished with the exact same manual steps, and therefore it is highly repetitive in nature. Fortunately for him, he can automate the process and execute it in a matter of seconds. While previously he was taking much more to achieve the same output.\n\nWe will use an extremely simple example to show how to create macros in Google Sheets. Because an advanced example is beyond the scope of this article. We recommend you going through <a href=\"https:\/\/developers.google.com\/apps-script\/articles\/tutorials\" target=\"_blank\" rel=\"noopener noreferrer\">this link<\/a> to learn the advanced concepts. The program we are going to write, for the purposes of demonstration in this article, does the following:\n<ul>\n \t<li>Inserts a value \"Hello world!\" in the cell A1.<\/li>\n \t<li>Changes the font to 'Calibri'.<\/li>\n \t<li>Changes the font size in cell A1 to 14.<\/li>\n \t<li>Fills the cell A1 with yellow color.<\/li>\n<\/ul>\nIn order for us to get there, we need to navigate to <strong>Tools &gt; Script editor<\/strong>.\n\n<strong>Example<\/strong> <img class=\"aligncenter size-full wp-image-7495\" src=\"https:\/\/static.sheetgo.com\/wp-content\/uploads\/2017\/11\/macros1.png\" alt=\"Create macros in Google Sheets - Illustration 1\" width=\"755\" height=\"335\">\n\nOn doing that, it will provide us with a workspace where we can write and execute our program in a separate tab. On the <strong>Script editor<\/strong> window, we write the code as shown in the snapshot below. Before we&nbsp;click on the <strong>Run<\/strong> button, we may want to <strong>Save<\/strong> it using the floppy disk icon.\n\n<strong>Example<\/strong> <img class=\"aligncenter wp-image-7498 size-full\" src=\"https:\/\/static.sheetgo.com\/wp-content\/uploads\/2017\/11\/macros2.png\" alt=\"Create macros in Google Sheets - Illustration 4\" width=\"823\" height=\"271\">\n\nWhen we try to execute this program, it might ask us to authenticate for the very first time. Here's the result after the program finished its execution.\n\n<strong>Example<\/strong> <img class=\"aligncenter size-full wp-image-7499\" src=\"https:\/\/static.sheetgo.com\/wp-content\/uploads\/2017\/11\/macros3.png\" alt=\"\" width=\"814\" height=\"462\">\n<h4>Conclusion<\/h4>\nThat was a fairly simple example that explains how to create macros in Google Sheets. However, the real-time applications can get very complex that usually simplifies a lot of stuff, which otherwise would have been difficult to achieve.\n<h4>Advantages<\/h4>\nThe Google Apps script is very similar to Office VBA. But in comparison, Google Apps script offers much more benefits than the traditional VBA does.\n<ol>\n \t<li>VBA runs on a client machine. Whereas&nbsp;Google script runs on the cloud taking its reach and scale are much higher and more flexible. One can even build web-based applications using the Google script. But we can't achieve that with VBA, that at the most can integrate with web applications using an API.<\/li>\n \t<li>We can build user interfaces using both VBA and Google script. The former is constrained when it comes to design (we can only build user forms). But with the latter, we can also leverage the technologies such as HTML, CSS, and Javascript.<\/li>\n \t<li>The list of data types in VBA is limited, as it is still relying on a relatively older technology. While Google script is based on Javascript, which is one of the core web technologies. Therefore we can bank upon its object-oriented elements, flexible data structures, and numerous utilities and build upon that.<\/li>\n<\/ol>","_et_gb_content_width":"","footnotes":""},"categories":[37],"tags":[39,28],"class_list":["post-254707","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-google-sheets-features","tag-connections-t","tag-spreadsheets"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.sheetgo.com\/es\/wp-json\/wp\/v2\/posts\/254707","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.sheetgo.com\/es\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.sheetgo.com\/es\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.sheetgo.com\/es\/wp-json\/wp\/v2\/users\/40"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sheetgo.com\/es\/wp-json\/wp\/v2\/comments?post=254707"}],"version-history":[{"count":0,"href":"https:\/\/www.sheetgo.com\/es\/wp-json\/wp\/v2\/posts\/254707\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.sheetgo.com\/es\/wp-json\/wp\/v2\/media\/254716"}],"wp:attachment":[{"href":"https:\/\/www.sheetgo.com\/es\/wp-json\/wp\/v2\/media?parent=254707"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sheetgo.com\/es\/wp-json\/wp\/v2\/categories?post=254707"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sheetgo.com\/es\/wp-json\/wp\/v2\/tags?post=254707"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}