
The method takes two arguments as input: (1) the name of the range (2) the range itself. To create a named range using Apps Script, use the setNamedRange() method of the Spreadsheet object. Creating a named range using Google Apps Script When you enter a name that is not valid, the UI will warn you. For example, you might get an error if you give your range a name like "A1:B2" or "R1C1:R2C2." They can't be in either A1 or R1C1 syntax.

They can't contain any spaces or punctuation. They can't start with a number, or the words "true" or "false." They can contain only letters, numbers, and underscores. Then create the named range from the sidebar by entering a name and selecting the range.Īccording to Google's documentation, the following restrictions apply to names of ranges. Select Data -> Named ranges from the menu. Your browser does not support HTML5 video. Then enter a name for this range and select Done. Select a range, right click and select Define named range. There are two ways to create a named range using the Google Sheets UI:ġ. Creating a named range using the Google Sheets UI There are two ways to create a named range: (1) manually using the Google Sheets UI and (2) using Apps Script code.
#PRINT SELECTION IN GOOGLE SHEETS HOW TO#
How to create a named range in Google Sheets? This prevents errors that result from formulas using an outdated range reference. If you need to make changes to a range that is used in multiple formulas and scripts, you only need to make this change in one place if you're using a named range.Īll of the formulas and scripts will immediately use the edited range. You only need to edit range references in one place Therefore, it is a best practice to name ranges that get used in multiple places in your spreadsheet. Similarly, you can think of a range in a spreadsheet as a variable that references an array of data. Doing so helps others read and understand your code. Giving variables a meaningful descriptive name is a best practice in coding. Make your formulas and scripts easy to read and understand There are several benefits to giving meaningful names to ranges in your spreadsheet. Why should you use named ranges in Google Sheets? The basics of coding in Google Apps Script. How to read data from and write data to a range in Google Sheets using Google Apps Script. This tutorial will assume that you are familiar with: Then, use these names in formulas and scripts in place of their A1 notation.

Therefore, it is a best practice to assign names to ranges that get used in multiple places in your spreadsheet. of cells to select text box, and then choose Select random cells in the Select Type list box, see screenshot 3. Giving variables a meaningful descriptive name is a best practice in coding. In the Sort Range Randomly dialog box, under Select tab, enter the number that you want to select the cells in the No. Each client's address information has been kept with each corresponding name.★ Naming ranges is a best practice that you should follow In the image below, the Name column has been sorted to display client names in alphabetical order. Related information across each row is kept together when the sort is applied. Sort sheet organizes all of the data in your spreadsheet by one column.When sorting data, it's important to first decide if you want the sort to apply to the entire sheet or to a selection of cells. You will also learn how to filter data to display only the information you need.

In this lesson, you will learn how to sort data to better view and organize the contents of your spreadsheet. You can sort your data by arranging it alphabetically or numerically, or you can apply a filter to narrow down the data and hide some of it from view. Google Sheets allows you reorganize your data by sorting and applying filters to it. As you add more content to your spreadsheet, organizing information in it becomes important. Google Sheets allows you to analyze and work with a significant amount of data. en/googlespreadsheets/working-with-functions/content/ Introduction
