Automatically Sort Data in Google Sheets

Поділитися
Вставка
  • Опубліковано 5 січ 2025

КОМЕНТАРІ • 252

  • @kevinsaint20
    @kevinsaint20 3 роки тому +4

    Thank you! The weight lifting coach at my school uses Google Sheets to input scores at the meets and he said his biggest gripe was that the totals don’t sort so the other teams know who is currently winning, etc. Used your functions and just had to change the ‘column’ condition inside the if statement from “column === max” to “column

    • @ExcelGoogleSheets
      @ExcelGoogleSheets  3 роки тому +1

      Great!

    • @kevinsaint20
      @kevinsaint20 3 роки тому

      @@ExcelGoogleSheets if there were several other pages that I wanted to do a similar thing for, would I have to create an entirely different script? Having trouble replicating it. In the other sheets, I can’t even use the sort filter for some reason. You can see it sort for a split second and then it goes back to the way it was immediately

  • @alanis7857
    @alanis7857 2 роки тому +7

    In case you don't find "Script Editor" under tools, it might be under extensions now.

  • @imputedrighteousnessminist2474
    @imputedrighteousnessminist2474 2 роки тому

    FINALLY!!! ALL the other sites--except for one or two which weren't good at teaching IMO, kept mentioning the filtering, which is VERY annoying, since it's not dynamic. THANK YOU THANK YOU THANK YOU!!! WHAT A HUGE HELP!!! IT LOOKS AWESOME!!! :) :) :)

  • @suprantes
    @suprantes Рік тому

    After seeing this tutorial 30++ times
    I can do on my own
    Thank you Sir

  • @RoseLK
    @RoseLK 3 роки тому +14

    Hi, thanks a lot! Wondering if we can sort multiple columns by using Script editor? Same as when we choose Data > Sort Range > Advanced > Choose multiple columns

    • @BuGuedes
      @BuGuedes 9 місяців тому +1

      Yes, you can. Instead of stopping at one column description, you may keep going.
      Exemple:
      range.sort( [
      {column: 3, ascending: true}, // sorted by column 3
      {column: 4, ascending: true}, // then sorted by column 4
      {column: 1, ascending: true}, // then sorted by column 1
      {column: 6, ascending: true} // then sorted by column 6
      ])

  • @phamvanthienfplhcm7543
    @phamvanthienfplhcm7543 2 роки тому

    You are a living god among n, a legend worthy of praise. What you've uploaded here, will echo into eternity!

  • @lukemenzel3513
    @lukemenzel3513 2 роки тому +2

    I am having trouble once I get to timestamp 8:44. When I run the script it will sort the values how I want them to but when I input a new number into the last column it does not auto sort. What could I be doing wrong? Any feedback would be greatly appreciated.

  • @AadityaDwivedi-o2c
    @AadityaDwivedi-o2c 10 місяців тому +1

    This works if I am making the edits manually, but not when the data is pushed in through an automated Zap process. can anyone help me out here please?

  • @cmozify
    @cmozify 3 роки тому +23

    I've truly appreciated many of the videos you're shared. As a newbie to Apps Script, I attempted replicating to "autosort" only the active sheet but encountered this error:
    >> TypeError: Cannot read property 'range' of undefined
    All function errors including onEdit: gs:2 and gs:19
    const range = currentSheet.getRange(2,1,currentSheet.getLastRow()-1,7)
    Only two things are different from your video example: 1) my table has data starting at Column 1 instead of Column 2 and 2) the active sheet is called "Stat Journal". What missteps have I done? Pointers and trouble-shooting tips would be appreciated!
    -------- (COPIED CODES) --------
    function mySort(e){
    const row = e.range.getRow()
    const column = e.range.getColumn()
    const ss = e.source
    const currentSheet = ss.getActiveSheet()
    const getSheetName = currentSheet.getSheetName()
    if(!(currentSheetName === "Stat Journal" && column === 7 && row >= 2)) return
    const range = currentSheet.getRange(2,1,currentSheet.getLastRow()-1,7)
    range.sort({column: 7, ascending: false})
    }
    function onEdit(e){
    mySort(e)
    }

    • @sam32rahman
      @sam32rahman 2 роки тому +11

      Same thing is happening to me...everything worked fine until he started moving things around for personal preference.

    • @marvinjaysamalca4988
      @marvinjaysamalca4988 2 роки тому +7

      Any fix on this?

    • @theragingpizza937
      @theragingpizza937 3 місяці тому

      Hey I know this is two years late but the way to fix this is by making this a trigger. (Essentially, the code won't work if you press run from the script editor but it WILL work in practice. To make it a trigger do the following:
      In the Google Sheets Script Editor, go to Triggers (the clock icon on the left sidebar).
      Click on Add Trigger.
      Set it to trigger onEdit and ensure the event type is "From spreadsheet" and "On edit".
      I renamed the project to 'AutoSort' and just had it run the project. Hope this fixes it! If not lmk
      (shoutout to ChatGPT)

  • @enigma369org
    @enigma369org 2 роки тому

    DUDE YOURE 🔥🔥🔥🔥🔥 THANK YOU!!!!

  • @garychadwick1240
    @garychadwick1240 3 роки тому +3

    Everything you teach works perfectly and is incredibly useful. Thank you!

  • @slalomdrags
    @slalomdrags 2 роки тому +1

    what if I have a function already in the last column that I want to auto sort? I tried auto sorting with the simple fx=SORT(range, sort_column, is_ascending) and it wouldn't do it because I already had a SUM function for that column from the 2 columns to the left of it. Any suggestions?

  • @Paul-ly1pw
    @Paul-ly1pw 8 місяців тому +1

    Brilliant video, thank you. I’ve been trying to make something similar work and failed until now.
    Can I ask how you code an extra feature? I have a jobs list and there is a column for the status (new, assigned, completed) but also a priority column.
    I would like to sort by status but within each status, I would like to sort by priority. how would i do that?

  • @blizzardy858
    @blizzardy858 5 місяців тому

    i'm having an issue where it's only checking the first number, but the code looks exactly the same
    but also something weird: i enter 11.12, and 10.98, but 11.12 goes to the top, yet i have the sort set to ascending: true
    however the sorter has functionality, it is just doing the wrong thing

  • @PositivelyNegativeOfficial
    @PositivelyNegativeOfficial 3 роки тому

    How would I do this if I was using text instead of numbers. I’m wanting to mark certain things as “active” and “inactive” with the inactive items auto sorted to the bottom.

  • @NTR-OTC
    @NTR-OTC 2 роки тому +1

    Your tips are great, thank you. I have a question and a scenario and I don't explain myself well so please, hang in there with me while I try. I have two live feed cameras that track trains. We keep track of all trains that pass us on Google Spreadsheets on a very impressive-looking log. We know how long it takes to get from one point to another from one cam to the other. What I am thinking of is when we enter a time on one location, somehow the background color changes on the other location's time slot for 15 minutes to a light color. Then 5 minutes a darker shade, then 5 minutes a darker one. After 30 minutes, or whatever prescribed time, after the train was due, I was kind of hoping to make the background change to make it appear to be blinking. If I made myself clear, is something like this even possible and if so where would I go to learn how to do this?

  • @AJ_9202
    @AJ_9202 2 роки тому

    Hello!
    Thank you very much. Is it possible to do this on different sheets. In this case the script runs on "My Sheet". Lets say that I have another sheet that is called "Adams Sheet" is it possible to have to different scripts running at the same time on edit? I am not getting to work. Would appreciate an answer. Thank you

  • @NurAfiqahSalman
    @NurAfiqahSalman Рік тому

    Hey there , i would need to edit a data sheet that has no amount but instead of “completed” “Pending” “ongoing”. How to i edit those in the Script Editor.

  • @alifitroni95
    @alifitroni95 3 роки тому +2

    Why it not work on my spreadsheet ?
    TypeError: Cannot read property 'range' of undefined

    • @theragingpizza937
      @theragingpizza937 3 місяці тому

      Hey I know this is two years late but the way to fix this is by making this a trigger. (Essentially, the code won't work if you press run from the script editor but it WILL work in practice. To make it a trigger do the following:
      In the Google Sheets Script Editor, go to Triggers (the clock icon on the left sidebar).
      Click on Add Trigger.
      Set it to trigger onEdit and ensure the event type is "From spreadsheet" and "On edit".
      I renamed the project to 'AutoSort' and just had it run the project. Hope this fixes it! If not lmk
      (shoutout to ChatGPT)

  • @ge8449
    @ge8449 3 роки тому +2

    Hello. Thank you very much for your explanation on this video. I have a question regarding to sort an entire row, if X cell have value "Y" or X cell have TRUE value from checkbox. So for this case, if it cell have crossed, the entire row will automatically sorted to the bottom. Could you please make the video for this problem? Thank you in advance

  • @m820683
    @m820683 2 роки тому

    Thank you very much this is a great video, learned and takes a lot.
    I am from Mexico City, even though my English is somewhat limited, I felt that I should at least thank you.
    Best regards.

  • @rossettekylabalunan4241
    @rossettekylabalunan4241 2 роки тому

    hi! quick question, how can i add this function to a different sheet on the same file, though it has a different number of columns. do i just repeat the same program?

  • @sbhanuprakash9
    @sbhanuprakash9 3 роки тому +3

    This is awesome!!. Is it possible to sort the data with a specific date which we enter on any cell and it should sort ascending order according to the specified date. can this be done? It would be a great help for me.

  • @ksugaris6941
    @ksugaris6941 Рік тому

    Thank you for your knowledge sharing. one step further for slicker appearance and better fuctionality would be to have a separate line only for input and when finish input automatically sort in the table.

  • @brianb4792
    @brianb4792 Рік тому

    The auto-sort script is great but only sorts for my account, the account Owner. The Sheet is shared with three other Editors. Auto sort does not work for them at all. Any insights would be greatly appreciated. Thank you for the great tutorial!!

  • @itzshowtime__4800
    @itzshowtime__4800 3 роки тому +1

    Thank you for the quick answer to my questions !

  • @Guesshaus
    @Guesshaus 10 місяців тому

    Entered this function autoSort(){
    const ss = SpreadsheetApp.getActiveSpreadsheet()
    const ws = ss.getSheetByName('TRANSACTIONS')
    const range = ws.getRange(1,2,ws.getLastRow()-1,7)
    range.sort({column: 1, ascending: true})
    } got Exception: Cell Reference out of range... I am sorting by column 1 by a date which I will enter last as you indicated using the last column instead. What is the issue here?

  • @DWisinIT
    @DWisinIT Рік тому +1

    🥰AWESOME THANKS! Can you please show one where it sorts like this, but it is ordered in a specific way for example: On edit of Column C, it orders the data : NorthEast, South, West, MidWest ?

  • @JaleyCWD
    @JaleyCWD Рік тому

    Thank you! So quick question: my sheet is now auto-sorting when I manually add a new row, but data that populates from google form responses does not automatically get sorted. Anyone know how to fix this?

  • @kumar_dv
    @kumar_dv 3 роки тому

    This video is very much helpful and handy. Great learning of basics. Thanks a TON !!.

  • @alliillilliii4365
    @alliillilliii4365 3 роки тому

    How do I make sure so that when anyone change the sheet, the script will trigger? For now it only work when I edit the sheet?

  • @williamdutton3321
    @williamdutton3321 2 роки тому

    Is there a way to make this work for multiple work sheets within a spreadsheet? I've tried making a script for each sheet however it only auto sorts the sheet with the most recent executed script. I'm super green to writing scripts... thanks for the help!

  • @austincrouse5991
    @austincrouse5991 3 роки тому +2

    I continually receive an error indicating "Cannot read property 'range' of undefined." for line 2. Does anyone have any thoughts?

    • @MagickUnleashed
      @MagickUnleashed 2 роки тому +1

      I am getting the same error. I did everything the same so not sure what’s wrong.

    • @theragingpizza937
      @theragingpizza937 3 місяці тому

      Hey I know this is two years late but the way to fix this is by making this a trigger. (Essentially, the code won't work if you press run from the script editor but it WILL work in practice. To make it a trigger do the following:
      In the Google Sheets Script Editor, go to Triggers (the clock icon on the left sidebar).
      Click on Add Trigger.
      Set it to trigger onEdit and ensure the event type is "From spreadsheet" and "On edit".
      I renamed the project to 'AutoSort' and just had it run the project. Hope this fixes it! If not lmk

  • @jefersontamiozzo3875
    @jefersontamiozzo3875 Рік тому

    Hello, thank you very much for your tips, they were of great help. A doubt: After performing the auto sort, I have a column in which, after being filled, the entire line is protected. How could I unite these two functionalities since, after being protected, the line numbers do not change in Protected Pages and Intervals. I would like after performing the auto sort and protection, the protected lines would adjust themselves as new data were inserted.

  • @ikhlaasarif
    @ikhlaasarif 2 роки тому

    This is such a beautifully detailed video!

  • @jayliu9998
    @jayliu9998 3 роки тому +1

    Very helpful, thank you! and can you plz tell me how to stop the script if I don't want the sheet to be sorted automatically?

  • @venkab5438
    @venkab5438 3 роки тому

    @ Learn Google Spreadsheets
    is it possible to auto sort based on different row colors?

  • @imsankarb
    @imsankarb Рік тому

    Thank you for the great tutorial! Is it possible to apply autosort on more than one tab in Google Sheets with different conditions?

  • @kitekite8597
    @kitekite8597 2 роки тому

    does this work on google sheets app too when i sync it?

  • @vcfborges
    @vcfborges 3 роки тому

    hi thanks for the tutorial, I am trying to implement it with a doPost method where I add rows to the sheet but it does not recognize me as an event that causes the values ​​to be ordered according to the column I choose, it only works when I edit a value of that column on the sheet, how could I do?

  • @bluestreak711
    @bluestreak711 2 роки тому

    How do I sort by column instead of by row? I need to sort horizontally instead of vertically.

  • @hemantdafda2028
    @hemantdafda2028 3 роки тому

    Very useful and quite good explanation. Thanks a lot dear makers.

  • @pinkbunny92
    @pinkbunny92 2 роки тому

    Thanks!

  • @JovanSilvera
    @JovanSilvera Рік тому

    What if you would like to sort by multiple criteria?

  • @arishmanalastas4781
    @arishmanalastas4781 3 роки тому

    Hello! does this do even if the data is edited that comes from another sheet because it's linked?

  • @royz_1
    @royz_1 3 роки тому +1

    Exactly what I needed. Thanks!

  • @MegaAcord
    @MegaAcord Рік тому

    Thank you! Great Video. Nevertheless, I'm having a problem when I copy and paste new data at the end of the sheet. The onEdit() doesn't refresh. It seems to work only when I type new data in the desired cell. Any suggestions? Thank you again.

  • @samway2221
    @samway2221 2 роки тому

    Hey brother, this all works great for me, no issues,
    But is there a way for me to pick & choose which 'sheets' I want this added to?
    For example I have "XYZ Group of Sheets" which contains Sheet1, Sheet2, Sheet3 within the "XYZ Group of Sheets".
    Say I wanted to add this script formula to Sheet1 & Sheet3, is this possible?

  • @ramuakula8225
    @ramuakula8225 3 роки тому

    it's very useful to me ....Thank you Very much🙏👍 Sir...

  • @tonyharion9816
    @tonyharion9816 3 роки тому

    Super cool!! I have to get my hands on training some more scripts for sheets!

  • @goldeneagle8259
    @goldeneagle8259 2 роки тому

    Now it works, thanks for the tutorial!

  • @Sus_Sou
    @Sus_Sou 3 роки тому +1

    Thank you for the video.
    Your video really help me.

  • @Sulaimangalib
    @Sulaimangalib 3 роки тому

    How to do a universal conditional format for multiple workbook?

  • @GiladOfir
    @GiladOfir 3 роки тому +1

    Great video, should we copy the script from the video or there is easier way to get it? 😃

  • @estanciahighschoolbaseball3610
    @estanciahighschoolbaseball3610 3 роки тому

    Hello - is there anyway to change the function so it sorts only when the active spreadsheet is edited, rather than when any tab within the sheet is edited?

  • @entrypointadvsiornetwork3338
    @entrypointadvsiornetwork3338 3 роки тому +1

    This video was great! I've seem to run into an issue however. I'm sending form entries via Gravity Forms to my Google Sheet through a zapier integration, and when it adds/updates a row, including the trigger column (Entry Date) that I am trying to sort by, it doesn't seem to trigger as an edit? If I manually change it or manually add a row to the sheet, it works no problem. Anyone have any thoughts?

    • @ExcelGoogleSheets
      @ExcelGoogleSheets  3 роки тому +1

      This will only be triggered from manual edits.

    • @entrypointadvsiornetwork3338
      @entrypointadvsiornetwork3338 3 роки тому

      @@ExcelGoogleSheets Do you have any recommendation for what I should look into for automatic edits?

    • @ExcelGoogleSheets
      @ExcelGoogleSheets  3 роки тому

      Check if whatever system you use for automation has a callback or webhook implementation. Your question has more to do with your automation system than Google Sheets.

  • @goldeneagle8259
    @goldeneagle8259 2 роки тому +1

    it works, when entering manually, which is great. But doesn't when I append using API, can you advise why? Probably need some other function, than onEdit().
    Now I fixed it. Had to create a custom trigger running this sort function on 'onChange' event. Works like a charm, thanks for this tutorial!

    • @mumtahina118
      @mumtahina118 Рік тому

      Could you tell me how you got it to start autosorting?

  • @uThirstyP
    @uThirstyP 3 роки тому

    Great video! Thank you! 🙏🏼
    Question: Can this be used to auto sort any check box ☑️ to the top of the list if it’s check

  • @kevinspaeth5895
    @kevinspaeth5895 2 роки тому

    I have been playing around with the code tonight and I can not get it to work properly, for what I need done. In short, I have several rows of data being sorted by the date entered in column B, after the input in Column G (7), but also want the sort to work on the same row if there is data entered into Column H (9). I want the sort to work with sorting by the dates in column B if there is a Debit or Credit value (Column G or H). I have tried many times to play around with the code to get this to work, but either the Apps Script pukes or the sort will not run. If you can help, that would be great! Here is the code I have currently:
    function autoSort() {

    const ss = SpreadsheetApp.getActiveSpreadsheet()
    const ws = ss.getSheetByName("Sheet1")
    const range = ws.getRange(2,2,ws.getLastRow()-1, 8)
    range.sort({column: 2, ascending: true})
    }
    function onEdit(e){
    const row = e.range.getRow()
    const column = e.range.getColumn()
    if(!(column === 7 && row >=2)) return
    //if(!(column === 8 && row >=2)) return
    autoSort()
    //if(!(column === 7 && row >=2)) return
    //if(!(column === 8 && row >=2)) return

    autoSort()
    }
    My headers for my spreadsheet are as follows:
    DATE (**) SECURITY ACTION QUANTITY (or 2:1 Split ex.) PRICE PER SHARE PAYMENT (-) DEPOSIT BALANCE
    Column A is in front of the Date column shown above, so the Date column is column 2.
    I hope I explained it well enough on what I am trying to get done. As of right now, if I enter a row of data, when I put a value in the Payment column, the row will be sorted with the data directly above, by the date entered for that particular row being added into the spreadsheet.
    Thanks!
    Kevin

  • @asevero
    @asevero 3 роки тому +1

    Edit: the script is working, but I don't know why this error keeps showing when trying to run the script.
    I am trying to run the script but this error appears: Error
    TypeError: Cannot read property 'range' of undefined
    autoSort @ Code.gs:2
    Double checked many times and can't find the problem! Help please!

    • @ExcelGoogleSheets
      @ExcelGoogleSheets  3 роки тому +1

      You can't manually run this function, because it can't work without an "event". It needs to automatically run when you make changes on the spreadsheet.

    • @asevero
      @asevero 3 роки тому

      @@ExcelGoogleSheets Thanks! It was working but I did not understand the error. Now I got it.

  • @amirbehvar
    @amirbehvar 3 роки тому

    very nice vid!
    I have two spreadsheets, I put the data in the first one and based on criteria data will be shown on the second spreadsheet, I was wondering if there was a script (I currently do it with filters manually) that I could auto hide blank rows on the second sheet and as soon as they get data they turn unhide.
    Thank you

  • @HPCSolutions
    @HPCSolutions 9 місяців тому

    Awesome, content, didn't know I could do this. Do you have a tutorial on sorting by a specific row? What is its not the last column. I want to sort a list by number of hospital beds. But I don't want to change the total count at the bottom of the page. I want to sort the list of hospital names, by the Highest number of Hospital Bed count. Is there a video, I could watch to figure this out from? Please and thank you for your time.

  • @runic6724
    @runic6724 3 роки тому +2

    I have done my code exactly like yours except with values from my sheet in it and I'm getting error "Cannot read property 'range' of undefined". I cannot tell what I'm doing wrong. Here's my code. Help?
    function autoSort(e){
    const row = e.range.getRow()
    const column = e.range.getColumn()
    const ss = e.source
    const currentSheet = ss.getActiveSheet()
    const currentSheetName = currentSheet.getSheetName()
    if(!(currentSheetName === "School Assignments" && column === 5 && row >= 2)) return
    const range = currentSheet.getRange(2,1,currentSheet.getLastRow()-1,6)
    range.sort({column: 5, ascending: true })
    }
    function onEdit(e){
    autoSort(e)
    }

    • @theragingpizza937
      @theragingpizza937 3 місяці тому

      Hey I know this is two years late but the way to fix this is by making this a trigger. (Essentially, the code won't work if you press run from the script editor but it WILL work in practice. To make it a trigger do the following:
      In the Google Sheets Script Editor, go to Triggers (the clock icon on the left sidebar).
      Click on Add Trigger.
      Set it to trigger onEdit and ensure the event type is "From spreadsheet" and "On edit".
      I renamed the project to 'AutoSort' and just had it run the project. Hope this fixes it! If not lmk
      (shoutout to ChatGPT)

    • @theragingpizza937
      @theragingpizza937 3 місяці тому

      just realized the 'shoutout to chaptgpt make it seems like I'm a bot. I'm not 💀💀

  • @p8196
    @p8196 2 роки тому

    It didn't work for me. I'm using Appsheet to add a row to a google sheet and for some reason the script does not activate. It works perfect when I add a row manually. Any suggestions?

  • @itsdylpickles2335
    @itsdylpickles2335 2 роки тому

    Is there a way to have it autoSort by multiple columns using this script (Ex. have sales be sorted within each region that is sorted)? I tried to have two statements under the .sort for both columns but it didn't work. I'm not very knowledgeable on this stuff so help would be appreciated.

    • @ExcelGoogleSheets
      @ExcelGoogleSheets  2 роки тому

      .sort([{column: 2, ascending: false}, {column: 1, ascending: true}]);

  • @roshanbothra8345
    @roshanbothra8345 3 роки тому +1

    It's nice, can you tell us, is it possible to auto highlight the active cell in sheets

    • @ExcelGoogleSheets
      @ExcelGoogleSheets  3 роки тому

      Even though it's technically possible, it would be very slow and unpleasant to work with.

  • @emadeddinferdowsi7979
    @emadeddinferdowsi7979 3 роки тому

    Really helpful! I looked so much for sth like this! Thank you!

  • @Cc-vu9mr
    @Cc-vu9mr 3 роки тому +1

    can you do it so it sorts it when all cells of the row aren't blank instead of when you edit the last one?

    • @ExcelGoogleSheets
      @ExcelGoogleSheets  3 роки тому

      Sure, you can add another if statement and check if the content in all columns != "" then sort.

  • @marsian8778
    @marsian8778 3 роки тому

    Excelente! Hope next time you discuss about auto lock cell after inserting some data using google script. Thanks!

    • @ExcelGoogleSheets
      @ExcelGoogleSheets  3 роки тому

      Doing this makes no sense based on how user authorization works.

  • @bryan.gonzales
    @bryan.gonzales 9 місяців тому

    how would I do this to sort by date?

  • @TheTramos00
    @TheTramos00 3 роки тому +1

    Simple and useful ! ...... Question : Your videos using Bootstrap, Materialize and Metro UI are really unique on UA-cam, may be anytime soon we can see more videos ? Maybe userforms for searching and displaying the results inside the userform ? userforms with data validation ? Also more of map(), reduce(), filter() ..... Thanks.

    • @ExcelGoogleSheets
      @ExcelGoogleSheets  3 роки тому

      I already have videos covering all of this. Check on the channel.

    • @TheTramos00
      @TheTramos00 3 роки тому

      @@ExcelGoogleSheets Thanks for the reply. I've seen most of them ! what I mean is if you are not going to make other videos with more examples about that.

    • @ExcelGoogleSheets
      @ExcelGoogleSheets  3 роки тому

      @@TheTramos00 There will be a new one coming tomorrow.

    • @TheTramos00
      @TheTramos00 3 роки тому

      @@ExcelGoogleSheets Great, I'll keep my eye out

  • @asevero
    @asevero 3 роки тому +1

    Thanks a lot! Great tutorial!

  • @haydeepenaranda5315
    @haydeepenaranda5315 2 роки тому

    THANK YOU!!! YOU HELPED ME A LOT!!!!

  • @roli3cash
    @roli3cash Рік тому

    I'm stuck, I cant get the auto to work, and also where can I find the Last row video ?

  • @empfox3596
    @empfox3596 3 роки тому +1

    Nice tutorials. I am learning a new things every day. when I do autosort function (onEdit),getting error. (12:07:44 PM Error
    TypeError: Cannot read property 'range' of undefined
    onEdit @ Code.gs:9) tried to figure it out, but no luck

    • @RakibHasan-zl1ms
      @RakibHasan-zl1ms 3 роки тому +1

      Facing the same problem.

    • @ExcelGoogleSheets
      @ExcelGoogleSheets  3 роки тому +3

      Don't manually run the function. It should run automatically when you make changes to the spreadsheet.

    • @RakibHasan-zl1ms
      @RakibHasan-zl1ms 3 роки тому

      @@ExcelGoogleSheets Its amazing! Works now perfectly. Thanks a lot from the core of my heart!

    • @mohdfitrimustapha6085
      @mohdfitrimustapha6085 3 роки тому +2

      @@ExcelGoogleSheets But it doesn't run automatically when changes made. Pls help.

    • @simonengler1776
      @simonengler1776 3 роки тому

      One question there: I get my data from a pivot table and when it has new data, nothing happens. Is there a solution to update the auto sort once it receives the automated data? Thank you so much!

  • @belgradeboy77
    @belgradeboy77 3 роки тому

    Thanks a lot for sharing these. I was wondering if there is a way to set up the script for multiple tables under the same sheet?

  • @ArmadusMalaysia
    @ArmadusMalaysia 2 роки тому

    Is it possible to keep the first row empty so that we can add details to it without scrolling all the way down?

  • @jhuensagun9526
    @jhuensagun9526 2 роки тому

    Thank you so much. Now I know how to automatically sort my google sheet. But how about if there are more than 1 conditions? say, I want to autosort by SALES, then by CATEGORY then by SALES REP. Is it possible? Thanks in advance

  • @Cirillu301
    @Cirillu301 3 роки тому

    Great vid!! I needed this to sort a list of pending invoices and I wanted to sort by supplier name which I placed in the first column. What i did at 09:50 in my case was simply to not include the onEdit function, created a button on the sheet and assigned it to the autoSort function so that once I entered all information, I simply click the button

    • @ExcelGoogleSheets
      @ExcelGoogleSheets  3 роки тому +1

      Cool!

    • @Harry-py6fq
      @Harry-py6fq 3 роки тому

      Any idea how to make it sort automatically when data changes automatically (without manual input)?

    • @estanciahighschoolbaseball3610
      @estanciahighschoolbaseball3610 3 роки тому

      Hi! Could you share the steps for creating this button? I love the onEdit function but when I need to make more than 1 edit to a row, I will sometimes lose the row after it auto sorts but before I'm done editing. I'd love a better option

    • @Cirillu301
      @Cirillu301 3 роки тому

      @@estanciahighschoolbaseball3610 to make the button, simply go to Insert > Image, then set the shape, text, colour etc as you want it, then simply assign it to the script function

    • @estanciahighschoolbaseball3610
      @estanciahighschoolbaseball3610 3 роки тому

      @@Cirillu301 I don't know how to assign it to the script function...writing scripts is allllll new to me (though I successfully managed to figure out the one in this video)

  • @benicio_cuna
    @benicio_cuna 2 роки тому +1

    If you could post the script on the description also, it would be very nice and simple.
    Then we use your explanation to update the script according to our data

    • @ExcelGoogleSheets
      @ExcelGoogleSheets  2 роки тому

      It's available to channel supporters on Patreon
      www.patreon.com/chicagocomputerclasses

    • @benicio_cuna
      @benicio_cuna 2 роки тому

      @@ExcelGoogleSheets ok. Thank you

  • @abhijeetkumar8830
    @abhijeetkumar8830 2 роки тому

    Hi
    Thanks for the superb video but in my case error is coming in the second line
    Cannot read property 'range' of undefined
    What should I do about this

  • @Heliuage
    @Heliuage 3 роки тому

    Is it possible to make autosorting in column "A" + column "B"?
    In case column "A" has the same value - it would by sorted by column "B"

    • @ExcelGoogleSheets
      @ExcelGoogleSheets  3 роки тому +1

      .sort([{column: 1, ascending: true}, {column: 2, ascending: true}])

    • @Heliuage
      @Heliuage 3 роки тому

      ​@@ExcelGoogleSheets Thank you for your answer.
      I used modifed mikebranski's script: gist.github.com/BenoitDuffez/71dada8033e733d57f251d92de638ba4
      The problem is that it works only onOpen and onInstall, whenever I try autoSort i receive following error:
      TypeError: Cannot read property 'getDataRange' of undefined
      autoSort @ code.gs:66
      Because of that it doesn't work, do you know what should be changed?

  • @thinusenslin
    @thinusenslin 2 роки тому

    Must the sheet be open to autosort or can I push data via api and it will still autosort?

    • @ExcelGoogleSheets
      @ExcelGoogleSheets  2 роки тому +1

      You can add a callback function to your script that is pushing data via api.

  • @siddharthjain6629
    @siddharthjain6629 3 роки тому

    Nice work. I appreciate your work

  • @allibarrett6809
    @allibarrett6809 2 роки тому

    Hi there, I'm trying to organize a Google Spreadsheet by date, earliest to latest. I followed along this video but not sure how your's is moving altogether. The date will move but the row will not move with the corresponding info. Any idea how to fix this? Thanks!

    • @ExcelGoogleSheets
      @ExcelGoogleSheets  2 роки тому

      Make sure you enter the right number of columns when you identify the range size.

  • @homeswithjp
    @homeswithjp 2 роки тому

    The function autoSort works when I ran but I can get the function onedit to work. I've done it over 10x. 🥺😢

    • @ExcelGoogleSheets
      @ExcelGoogleSheets  2 роки тому

      I'd suggest taking time to learn how onEdit works first. This video should help ua-cam.com/video/frAL7bJkU54/v-deo.html

  • @marlonmadrona1309
    @marlonmadrona1309 3 роки тому

    ​ @Learn Google Spreadsheets What if the column I want to sort is a formula?

    • @ExcelGoogleSheets
      @ExcelGoogleSheets  3 роки тому +1

      Sorting it should be the same, but you need to choose a different trigger column to initiate sorting.

    • @mumtahina118
      @mumtahina118 Рік тому

      @@ExcelGoogleSheets THANK YOU FOR THIS. I was literally so stumped as to why my code wouldn't make my google sheet automatically sort. I didn't realize that the formula in the column I picked as the trigger column was causing problems. This solved my hours on end searching for the solution.

  • @p1rturk598
    @p1rturk598 3 роки тому

    Where is the copy and paste section? I just need a working code to copy and paste onto my sheet.

  • @matosumi7622
    @matosumi7622 3 роки тому

    Hey, I have tried this but it does not work for me. In my case I need to Auto-Sort the data if the sheet changes in anyway. The data is entered by another worksheet (from google forms). Any idea how to fix that? If I enter anything manually it work. GREAT TUTORIAL

  • @RuhinazVlogs
    @RuhinazVlogs 3 роки тому

    Will it work if sheet name is changed?
    For ex: You are mentioning the sheet name as "My Sheet". If someone changes the sheet name will that gets auto change in script or not?

    • @theragingpizza937
      @theragingpizza937 3 місяці тому

      Probably not becasue the comparison is hardcoded

  • @danielbarrett7432
    @danielbarrett7432 3 роки тому

    I keep getting a "getSheetbyName is not a function" error when debugging - any ideas why it keeps saying that as I've heard it can mean the file is corrupted and a new one is required

  • @notherenotanywhere
    @notherenotanywhere 2 роки тому

    Seems to be working but I'm getting the error: "TypeError: Cannot read property 'range' of undefined autoSort @ AutoSort.gs:2". Should I be concerned?

  • @LT-R828
    @LT-R828 3 роки тому

    Thank you for this easy to follow video! Can you please explain the difference between the Sort Range and Create Filter function? The both seem similar. I was able to figure out how to do the Create Filter when there is only one header row/column but the my spreadsheet has the same header names in three or four different sections on the same sheet and I don't know how to do that. Is this even possible?

    • @ExcelGoogleSheets
      @ExcelGoogleSheets  3 роки тому +1

      Not with filters, but you can use sort on multiple separate ranges.

    • @LT-R828
      @LT-R828 3 роки тому

      @@ExcelGoogleSheets Thanks for answering my question. :)

  • @taylorgowan7970
    @taylorgowan7970 3 роки тому +1

    CAN ANYONE EXPLAIN WHY I AM GETTING A RANGE ERROR AND THIS IS NOT WORKING??
    function autosort(e){

    const row = e.range.getRow()
    const column = e.range.getColumn()
    const ss = e.source
    const currentSheet = ss.getActiveSheet()
    const currentSheetName = currentsheet.getSheetByName()
    if(!(currentSheetName === "Inspectors sheet" && column === 1 && row >=2)) return
    const range = currentSheet.getRange(2,1,currentSheet.getLastRow()-1,15)
    range.sort({column:1,ascending:true})
    }
    function onEdit(e) {
    const row = e.range.getRow()
    const column = e.range.getColumn()
    if(!(currentSheetName === "Inspectors sheet" && column === 1 && row >=2)) return
    autosort(e)

    }

    • @theragingpizza937
      @theragingpizza937 3 місяці тому

      Hey I know this is two years late but the way to fix this is by making this a trigger. (Essentially, the code won't work if you press run from the script editor but it WILL work in practice. To make it a trigger do the following:
      In the Google Sheets Script Editor, go to Triggers (the clock icon on the left sidebar).
      Click on Add Trigger.
      Set it to trigger onEdit and ensure the event type is "From spreadsheet" and "On edit".
      I renamed the project to 'AutoSort' and just had it run the project. Hope this fixes it! If not lmk

  • @hakanbilgin1836
    @hakanbilgin1836 2 роки тому

    Thank you for the information ! There are 8 columns available. I want to auto sort by 7th column. But after writing the 8th column, I want it to sort by the 7th column. Do you any advice? Thank u.

    • @ExcelGoogleSheets
      @ExcelGoogleSheets  2 роки тому

      It's the same, just in sort code use column 7.

    • @hakanbilgin1836
      @hakanbilgin1836 2 роки тому

      @@ExcelGoogleSheets I set it as the 7th column. But I don't want it to sort without filling the 8th column. Can you do something about this situation?

    • @ExcelGoogleSheets
      @ExcelGoogleSheets  2 роки тому

      Yes. Use the sort column as 7, but set the onEdit column to 8.

    • @hakanbilgin1836
      @hakanbilgin1836 2 роки тому

      @@ExcelGoogleSheets thank you. I did as you said. Was successful.
      But the data in the 8th column after the 7th column, where the sorting is, remains constant. I need your help. :)

    • @hakanbilgin1836
      @hakanbilgin1836 2 роки тому

      @@ExcelGoogleSheets
      function mySort(e){
      const row = e.range.getRow()
      const column = e.range.getColumn()
      const ss = e.source
      const currentSheet = ss.getActiveSheet()

      if(!(column === 8 && row >= 8)) return

      const range = currentSheet.getRange(8,2,currentSheet.getLastRow()-1,7)
      range.sort({column: 7, ascending: true})
      }
      function onEdit(e){
      mySort(e)
      }

  • @hiew04
    @hiew04 2 роки тому

    Hi, I copy paste your code but I get this, how to fix it?
    TypeError: Cannot read property 'range' of undefined

    • @ExcelGoogleSheets
      @ExcelGoogleSheets  2 роки тому

      Don't manually run the function, it should run when you make changes.

  • @hiptobedad
    @hiptobedad 3 роки тому +2

    This is really great, but I am getting an error: 'TypeError: Cannot read property 'range' of undefined'
    This is my code:
    function autoSort(e){
    const row = e.range.getRow()
    const column = e.range.getColumn()
    const ss = e.source
    const currentSheet = ss.getActiveSheet()
    const currentSheetName = currentSheet.getSheetByName()
    if(!(currentSheetName === "Phone Sheet" && column === 1 && row>=2)) return
    const range = currentSheet.getRange(2,1,currentSheet.getLastRow()-1,6)
    range.sort({column: 1, ascending: true})
    }
    function onEdit(e){
    autoSort(e)
    }

    • @ExcelGoogleSheets
      @ExcelGoogleSheets  3 роки тому

      const currentSheetName = currentSheet.getSheetByName()
      const currentSheetName = currentSheet.getSheetName()

  • @crisarlsydneygaviola8920
    @crisarlsydneygaviola8920 3 роки тому

    How to apply this to all sheets?

  • @bruno_veloso
    @bruno_veloso 3 роки тому

    Well done! Did you learn javascript first or did you go directly google appscript?

    • @ExcelGoogleSheets
      @ExcelGoogleSheets  3 роки тому

      I've learned JavaScript for other reasons. Contrary to what most people believe, I don't write apps script code very often.

    • @bruno_veloso
      @bruno_veloso 3 роки тому

      @@ExcelGoogleSheets i've been struggling learning javascript. Do you have any tip? Learning javascript so far is pushing me into learning html and css and i'm not intereted in developing websites, I'm more into self-service usage.

  • @CasualHobbyist
    @CasualHobbyist 3 роки тому

    Very helpful, thank you!!!