Тёмный
No video :(

Google Apps Script: Get Range in Sheets 

saperis
Подписаться 29 тыс.
Просмотров 18 тыс.
50% 1

In this video you will learn four different methods to get a specific range in Sheets with Google Apps Script.
00:00 Intro
00:20 getDataRange() method
2:00 getRange(a1Notation) method
3:25 getRange()
6:01 getRangeByName(name) method
👉🏽 If you're interested in leveling up your Google Apps Script skill have a look at our online course: https//courses.saperis.io
#GoogleAppsScriptGetRange #GoogleSheets #GoogleAppsScript #AppsScript #GoogleWorkspace #saperis #ChanelGreco
-----
saperis - Helping you become a Google Workspace Pro!
Sign up to our RU-vid channel for more Google Workspace, Gmail, Google Apps Script, Google Drive, etc. videos: / saperis

Опубликовано:

 

18 авг 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 76   
@frdata
@frdata 2 года назад
Exactly what I've been searching for. Comprehensive and clearly explained. You saved me a lot of time. Thank you so much
@saperis
@saperis 2 года назад
You're very welcome! 😃
@furfur001
@furfur001 2 года назад
I am new to Google App Script. Your tutorials are very well structurated and worked best for me. Thank you for that.
@saperis
@saperis 2 года назад
Glad it helped! 😀
@zaidkhan-nb1er
@zaidkhan-nb1er Год назад
ty love
@saperis
@saperis Год назад
You're welcome 😀
@lholhofox
@lholhofox 11 месяцев назад
Thank you very much for the video!! Very good and clear explanation! Keep'em coming!! ☺
@saperis
@saperis 11 месяцев назад
You are welcome! 😀
@vin81084
@vin81084 3 месяца назад
Thank you for this. Is there a way we can get multiple ranges in app script say A1:A5 and C1 to C5 ?
@janguita
@janguita 2 года назад
Gracias por tener un ingles tan claro. Lo entendí perfectamente. Y has sido muy didactica. Muy amable. Gracias!
@saperis
@saperis 2 года назад
Estoy feliz de que te haya gustado 😀
@marceldumitrescu1059
@marceldumitrescu1059 2 года назад
Thank you, for the help !
@saperis
@saperis 2 года назад
You're welcome! 😀
@ammarshbeb1840
@ammarshbeb1840 9 месяцев назад
Thank you very much for the video .. what about blanks and formulas ?
@saperis
@saperis 9 месяцев назад
Check the developer documentation to see how to retrieve this from a sheet: developers.google.com/apps-script/reference/spreadsheet
@janjongste5399
@janjongste5399 2 года назад
Thank you for the clear video. You really know how to teach! How would you use getRange when the first two parameters should be the row and column of the currentActiveCell followed up bij numRows and numColumns?
@saperis
@saperis 2 года назад
If you want to access the current active cell you can use the getCurrentCell() method. This gives you back a range. The getRange() method also gives you back a range. Just that here you define the range by passing in the parameters of row, column, row count and column count. You can't use the getCurrentCell() method together with the getRange() method.
@janjongste5399
@janjongste5399 2 года назад
@@saperis Thank you for the clear reply! ....kind regards Jan
@MrLococaco
@MrLococaco Год назад
Excelente, saludos desde Chile
@saperis
@saperis Год назад
Gracias 😀
@noorimpresiones1218
@noorimpresiones1218 Год назад
best video tutorial ever! please, createTextFinder tool for some videos in the future 🙏
@saperis
@saperis Год назад
Thanks for the feedback. I don't make any Apps Script videos on this channel anymore. See why: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-OHd_xEabivg.html
@googleguruji2553
@googleguruji2553 8 месяцев назад
Please make a video for getting data from the rows which have true values..
@saperis
@saperis 8 месяцев назад
Thank you for watching this video. I don't do any Apps Script videos anymore on this channel. But I invite you to check out the Google Workspace Developers RU-vid channel: www.youtube.com/@googleworkspacedevs
@fliich
@fliich Год назад
Thanks for this tutorial. Very clear and concise. I was wondering is there a way to getRange() with a parameter you set in your function or by getting the current row or current cell? I'm having a hard time conceptualizing it this way.
@saperis
@saperis Год назад
To understand what parameters you can use, check the official Apps Script documentation. That's the easiest way to find out how to use methods: developers.google.com/apps-script/reference/spreadsheet/sheet#getrangerow,-column
@alecallejas3043
@alecallejas3043 Год назад
Great explanation, I have a question: what if for example I want to store a cell value as a variable; Sheet1 Cell B2 value Is stored as "Sales". What method should I apply? Thank you!!
@saperis
@saperis Год назад
To get the content of one specific cell you can use .getValue() on the range. developers.google.com/apps-script/reference/spreadsheet/range#getvalue
@alecallejas3043
@alecallejas3043 Год назад
@@saperis Thank you!
@sudamshirke8243
@sudamshirke8243 2 года назад
Great..👍👍
@saperis
@saperis 2 года назад
Thanks ✌️
@Dziadaaa
@Dziadaaa Год назад
Hi, thank you for this video. I also need to get a hyperlink that is added on some part of the text in cells. I guess I need to use getActiveSpreadsheet function but I don't know how to do it.
@saperis
@saperis Год назад
With getAchtiveSpreadsheet you simply get the entire Google Sheets file that you currently have opened in your browser. Form there you need to use further methods to access the part of the data that you are interested in.
@user-jb8ke4dg6n
@user-jb8ke4dg6n Год назад
Excellent teacher with excellent lessons) Please, can you tell me why google script logger shows ranges in different ways? For example, in the video when you used a1Notation, all results appeared in one row (not in different rows for better presenting information as other examples). I have the same problem: when I use getRange() with all 4 parameters (4, 14, 1, 23) , console.log() show me 23 rows :)) How could I solve this problem?
@saperis
@saperis Год назад
The logger shows you the data just like Apps Script sees it. That's why it's not represented in columns but instead in one row. There is no way of changing that.
@ivanurbina2422
@ivanurbina2422 Год назад
I love your tutorial. Question: Is there a way to set the column size of a google sheet by using javascript? I have been looking but could not find one. I want to use javascript, not the manual method. The google sheet I created is by javascript (where I got most of the methods from you, thank you); I want to add the capability of sizing a range of columns. Greatly appreciated.
@saperis
@saperis Год назад
I had a look at the Apps Script developer documentation. I don't think it's possible to set the width of a column using Apps Script. developers.google.com/apps-script/reference/spreadsheet
@giuliabera8282
@giuliabera8282 2 года назад
Very interesting! I'm trying to get a variable range in a coulmn, so I think i need to get the range to lastRow of that Column. Is it possibile without a loop?
@saperis
@saperis 2 года назад
I wouldn't use a loop to get data from a spreadsheet. I would much rather use the getDataRange() method. It gives you back all the data no matter how many rows it contains.
@gokhanboyac7496
@gokhanboyac7496 Год назад
Hello, can we export a certain range field as example a1:f15 jpeg.
@saperis
@saperis Год назад
I think that should be possible. Check this video to find out how to export a Sheets file: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-xUovS4fwqsg.html
@HumanityMatters85
@HumanityMatters85 Год назад
could u plz make a video on how to get active user using app script. I have seen that if the user is not the owner then getActiveuser() function is not working desirably
@saperis
@saperis Год назад
Thanks for watching. I don't do any Apps Script or Google Workspace videos anymore. Find out why in this video: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-OHd_xEabivg.html
@Savag31
@Savag31 2 года назад
Hi how do i enable permissions. I went into the .json file and added the oauthScopes but it did not work
@saperis
@saperis 2 года назад
What for permissions are you trying to enable? In the video tutorial you can see that I simply click my way through the default permissions.
@Niroshmm
@Niroshmm 2 года назад
Hi I can't see the option Script editor in google Sheets, how to fix that?
@saperis
@saperis 2 года назад
Google has updated the Google Sheets menu since this video was made. Check Extensions > Apps Script.
@carlstonejunior
@carlstonejunior 2 года назад
is it possible to get ranges starting from the class Range? or do you always have to start from the class Sheet?
@saperis
@saperis 2 года назад
You have to start from the class Sheet or Spreadsheet.
@jwalbanker
@jwalbanker 2 года назад
Is there a way to get fixed selected cells from all sheets (except master sheet) to a master sheet? For eg, If I have a sheet for each day of a month and I want to compile data from all sheets to a master sheet
@saperis
@saperis 2 года назад
That should be possible. We have a video on how to copy content from one sheet to another that might offer some ideas on how to accomplish your goal: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-xmtwWKYLJHs.html
@jwalbanker
@jwalbanker 2 года назад
@@saperis Thanks for the revert! It does to some extent, but I want to get data prospectively from all new sheets made to a master sheet, but the data should be added in a different row each time so that I have a compiled data at the end.
@saperis
@saperis 2 года назад
@UC%F0%9F%98%80zKzrFTs7_vZGA3lU0IDSbQ Ok, well we have no video on what you are exactly trying to do. But I'm sure you'll get it done.
@jordan1048
@jordan1048 2 года назад
Great video! I just have one question about getNameByRange. When I try to use it, the log says its not a function but it shows the pop up dialog box when I input an argument. I then tried getNamedRange(Name) but it says that the input of a string is wrong. All I'm trying to do is get the length index of a column through script. Any help would be greatly appreciated!
@saperis
@saperis 2 года назад
As you learned through the video there are multiple ways to get data from a sheet. If you chose to use the getNamedRange method I'm guessing you have created a named range within your sheet. In that case the parameter passed into the method has to be the name of the range. So if I named my range Person_and_Scores I have to use the method like so ON THE SPREADSHEET and not on the sheet: getNamedRange('Person_and_Scores');
@jordan1048
@jordan1048 2 года назад
@@saperis Ah I see! Thanks!!
@janguita
@janguita 2 года назад
Those examples didn't work form me. I need the lastrow from lastcolumn. But lastcolumn don't have all the rows with values. So the last column have less values than the other columns. I can't find the right method for this issue. But I will find it! ;o)
@saperis
@saperis 2 года назад
Maybe also check the method getLastColumn(): developers.google.com/apps-script/reference/spreadsheet/sheet#getlastcolumn And also check getLastRow(): developers.google.com/apps-script/reference/spreadsheet/sheet#getlastrow
@carlostoledoFLA
@carlostoledoFLA 2 года назад
My google sheets in tools, don't show Script editor. Why?
@saperis
@saperis 2 года назад
Because Google updated the menu of Google Sheets since we've published this video. Go to 'Extensions' > 'Apps Script'.
@carlostoledoFLA
@carlostoledoFLA 2 года назад
@@saperis Thank's! Your videos are amazing! :)
@Naveenkumar-lq3ik
@Naveenkumar-lq3ik 2 года назад
Assume that c column has email_list , How to send in e-mail body the selected data A1:B7
@saperis
@saperis 2 года назад
Well, you would have to write a separate script to actually send out the email. Our video tutorial here only demonstrates how to get data from a specific range within a Google Sheet.
@DavenneChua
@DavenneChua 2 года назад
Is it possible instead of A1:B3. You instead use a cell with A1:B3
@saperis
@saperis 2 года назад
I'm not sure if I understand your question. Yes, you can get any range you want and it doesn't have to be the same I used.
@DavenneChua
@DavenneChua 2 года назад
@@saperis What I mean is... you used A1 notation as ( 'A1:B3') on your example. Is it possible to use a Cell value inside a sheet instead. Example G14 = A1:B3 So new A1 Notation would be range('G14') instead. When I tried it it didn't work.
@saperis
@saperis 2 года назад
@@DavenneChua The method expects an A1 notation and not a cell that contains A1 notations as its value. That's my assumption since both my tests and your tests have failed.
@DavenneChua
@DavenneChua 2 года назад
@@saperis i see... is there a way to change it as such? To Get range from a cell value then use it for getrange. Or is there simpler way. If none that's ok. Thanks for your replies. :)
@DavenneChua
@DavenneChua 2 года назад
@@saperis function ABCDEF() { var spreadsheet = SpreadsheetApp.getActive(); spreadsheet.setActiveSheet(spreadsheet.getSheetByName('SHEETNAME'), true); spreadsheet.getRange('C4:C49').setValue('ABCDEF'); } if possible I just need C4:C49 to be from a cell G14 = C4:C49
@dornescu.lucian
@dornescu.lucian Год назад
Hello, This line of code uses the id entered manually in the script let copyFile = DriveApp.getFileById('1GhpGpHM......').makeCopy(), copyID = copyFile.getId(), copyDoc = DocumentApp.openById(copyID), How could I use the ID that can be found manually written in the google spreadsheet, so that if I change it from the spreadsheet, it will also change automatically in the script. I have a list of IDs associated with some templates. I used : var ID_template = ss.getRangeByName('ID_template').getValue; and then let copyFile = DriveApp.getFileById(ID_template).makeCopy(), copyID = copyFile.getId(), copyDoc = DocumentApp.openById(copyID), but without any result. Can something be done about this?
@saperis
@saperis Год назад
The getRangeByName() method you are using is only for named ranges in a sheet. So that will never work the way you are using it. Instead, get that file ID by referencing the exact cell like ss.getRange('A1') or whatever cell it is in. Very important when using Apps Script: read the official documentation to find out what methods do. developers.google.com/apps-script/reference/spreadsheet
@TuanTran-db3uv
@TuanTran-db3uv 2 года назад
var ss = SpreadsheetApp.getActiveSpreadsheet(); var sheet = ss.getSheetByName('Thông tin liên hệ (Câu trả lời)'); var emailTo = sheet.getRange(sheet.getLastRow(), 3).getValue(); I don't khow why there is an error "Cannot read property 'getRange' of null"(Sorry, i'm new)
@saperis
@saperis 2 года назад
I can't tell by looking at the code you shared here. Maybe there is a typo?
@TuanTran-db3uv
@TuanTran-db3uv 2 года назад
@@saperis Thank you very much. I found the problem
Далее
JavaScript for Beginners: forEach loop
5:16
Просмотров 2,5 тыс.
How to VLOOKUP in Google Sheets with Apps Script?
17:16
Google Apps Script For Loop
19:09
Просмотров 19 тыс.
Google Apps Script Tutorial for Beginners
23:54
Просмотров 373 тыс.
How Google Apps Script Foreach Loop Works
11:37
Просмотров 10 тыс.
Google Sheets: onEdit Basics
10:56
Просмотров 19 тыс.
IMPORTRANGE Function in Google Sheets | Multiple Sheets
10:11
How To Get Spreadsheet Values Using Google Apps Script
10:24