{"id":15380,"date":"2023-07-28T09:00:00","date_gmt":"2023-07-28T00:00:00","guid":{"rendered":"https:\/\/www.autooffice.co.kr\/blog\/2023\/07\/28\/getting-values-from-range-a1a4-in-google-sheets\/"},"modified":"2025-09-15T18:26:08","modified_gmt":"2025-09-15T09:26:08","slug":"getting-values-from-range-a1a4-in-google-sheets","status":"publish","type":"post","link":"https:\/\/www.autooffice.co.kr\/en\/blog\/2023\/07\/28\/getting-values-from-range-a1a4-in-google-sheets\/","title":{"rendered":"Getting Values from Range A1:A4 in Google Sheets"},"content":{"rendered":"<p>This post is a corrected post after AI explains the code included in the book <a title=\"\" href=\"https:\/\/www.autooffice.io\/content\/ebizbooks-apps-script\" target=\"_blank\" rel=\"noopener\">&#8220;Google Apps Script 101: Building Work Automation For Free&#8221;<\/a>. Added a <s>strikethrough<\/s> when editing what AI has written, and added <span style=\"color: #ff3366;\">color<\/span> when edited by author<\/p>\n<h2>Table of Contents<\/h2>\n<ul>\n<li><a href=\"#summary\">Summary<\/a><\/li>\n<li><a href=\"#code\">Code<\/a><\/li>\n<li><a href=\"#code-explanation\">Code Explanation<\/a><\/li>\n<li><a href=\"#example\">Example<\/a><\/li>\n<li><a href=\"#ai-prompt\">AI Prompt<\/a><\/li>\n<\/ul>\n<h2 id=\"summary\">Summary<\/h2>\n<p>In this blog post, we will learn how to use Apps Script to get values from a specified range in Google Sheets. Specifically, we will focus on retrieving values from the range A1:A4.<\/p>\n<h2 id=\"code\">Code<\/h2>\n<pre>    function getA1A4Values() {\n      const value = SpreadsheetApp.getActiveSheet().getRange('A1:A4').getValues();\n      Logger.log(value);\n    }\n<\/pre>\n<h2 id=\"code-explanation\">Code Explanation<\/h2>\n<p>The provided code snippet defines a function named <code>getA1A4Values<\/code>. Inside the function, it uses Apps Script&#8217;s <code>SpreadsheetApp<\/code> class to access the active sheet and retrieve the values from the range A1:A4. The retrieved values are then logged to the Logger.<\/p>\n<p><span style=\"color: #ff3366;\">Retrieving data from A1:A4 is different from retrieving data from A1:E1 because the former involves fetching values from a column, while the latter deals with values from a row. A1:E1 represents a 2D array with a single row containing five elements, whereas A1:A4 represents a 2D array with four rows, each containing a single element. Understanding these differences is crucial as it forms the foundation for utilizing Apps Script in Google Sheets. <\/span><\/p>\n<p><span style=\"color: #ff3366;\">If you ask the AI for examples of each log, it would respond as follows:<\/span><\/p>\n<p>Data from range A1:E1:<br \/>\n[ [John, Alice, Bob, Mary, Eve] ]<\/p>\n<p>Data from range A1:A4:<br \/>\n[ [John], [Alice], [Bob], [Mary] ]<\/p>\n<h2 id=\"example\">Example<\/h2>\n<p>Before running the code, open a Google Sheet and activate the sheet from which you want to retrieve the values. Then, follow these steps:<\/p>\n<ol>\n<li>Click on the &#8220;Extensions&#8221; menu.<\/li>\n<li>Select &#8220;Apps Script&#8221;.<\/li>\n<li>A new tab will open with the Apps Script editor.<\/li>\n<li>Paste the provided code into the editor.<\/li>\n<li>Save the script by clicking on the floppy disk icon or using the &#8220;File&#8221; menu.<\/li>\n<li>Click on the play button to run the script.<\/li>\n<li>Open the &#8220;View&#8221; menu and select &#8220;Logs&#8221; to see the retrieved values logged in the console.<\/li>\n<\/ol>\n<p><span style=\"color: #ff3366;\">Since there is no context provided to AI, AI explained the basics.<\/span><\/p>\n<h2 id=\"ai-prompt\">AI Prompt<\/h2>\n<p>How can I retrieve the values from the range A1:A4 in Google Sheets using Apps Script?<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this blog post, we will learn how to use Apps Script to get values from a specified range in Google Sheets. Specifically, we will focus on retrieving values from the range A1:A4.<\/p>\n","protected":false},"author":1,"featured_media":15384,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"footnotes":""},"categories":[5,118],"tags":[512,69,521,7],"class_list":["post-15380","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-spreadsheet","category-apps-script","tag-ai-assisted","tag-script","tag-getvalues","tag-spreadsheet"],"translation":{"provider":"WPGlobus","version":"3.0.2","language":"en","enabled_languages":["ko","en"],"languages":{"ko":{"title":true,"content":true,"excerpt":true},"en":{"title":true,"content":true,"excerpt":true}}},"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.autooffice.co.kr\/en\/wp-json\/wp\/v2\/posts\/15380","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.autooffice.co.kr\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.autooffice.co.kr\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.autooffice.co.kr\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.autooffice.co.kr\/en\/wp-json\/wp\/v2\/comments?post=15380"}],"version-history":[{"count":3,"href":"https:\/\/www.autooffice.co.kr\/en\/wp-json\/wp\/v2\/posts\/15380\/revisions"}],"predecessor-version":[{"id":17213,"href":"https:\/\/www.autooffice.co.kr\/en\/wp-json\/wp\/v2\/posts\/15380\/revisions\/17213"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.autooffice.co.kr\/en\/wp-json\/wp\/v2\/media\/15384"}],"wp:attachment":[{"href":"https:\/\/www.autooffice.co.kr\/en\/wp-json\/wp\/v2\/media?parent=15380"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.autooffice.co.kr\/en\/wp-json\/wp\/v2\/categories?post=15380"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.autooffice.co.kr\/en\/wp-json\/wp\/v2\/tags?post=15380"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}