r/GoogleAppsScript • • Jul 20 '23

Question Help - where to start learning process?

Hey,

I'm an accountant whose really good at complex functions in sheets & excel. I see a huge benefit from learning Google App Script in my work, but I have no idea where to even start. Ideally I'd love to learn to pull data from outside sources to bring into my sheets. My work will pay for me to learn this, and I understand it'll take a long time.

My question here is, where do I even begin? Do you have any good suggestions of courses I could take?

Much appreciated!

12 Upvotes

11 comments sorted by

6

u/[deleted] Jul 20 '23

Learn JavaScript. You have to be good at it. Find existing examples, articles and keep practicing.

2

u/tallcoleman Jul 20 '23

I'd highly recommend https://eloquentjavascript.net/

it's free, has interactive examples and projects, and the introduction to regex chapter I think is really well written for a challenging topic (and I often find that kind of stuff helpful for apps script or REGEXEXTRACT)

3

u/Relzin Jul 20 '23

Start with =importdata as a function in the sheet.

Start to work towards pulling in the same data but NOT using importdata, and instead using a script.

I think starting with this as a project will get you used to things like calling a spreadsheet, determining what range is you're working with, and moving values to and from the spreadsheet. This gives you the ability to have a tab that you're familiar with that uses the built-in function, to see results, and you can then use the Google apps script engine to do some basic JavaScript to attempt the exact same thing as the importdata function, with your results being viewable in a spreadsheet as well!

3

u/Kanegarooo Jul 21 '23

If you don't currently have programming experience & you're just trying to learn for the Apps Script use-case then I suggest learning on a problem to problem basis. Its a lot easier to learn when you have real problems to work with.

For JavaScript, learn the basics:

The list could go on, but start with these more simple topics.

From here you can learn to break down your problems into parts.

Let's say you want to sum up some adjacent cells, these would be the broad steps:

  • Declare the workbook & sheet that contains your cells

  • getRange() of the cells and getValues() of the range

From here, there are a plethora of ways to add all of the value together so this is a good opportunity to walk you through what you may experience.

Assuming you learned about arrays, you may notice that the Apps Script docs tell you that getValues() results in this:

Object[][] — A two-dimensional array of values.

A two-dimensional array of value is a lot different than just an array, this is a roadblock for you.

Like I said, there are a lot of ways to do things in programming. Consider looking up:

'how to add all values in a two dimensional array JavaScript'

or

'two dimensional array to one dimensional JavaScript'

note, I'm adding JavaScript to the search because the syntax varies between languages

Additionally, consider using Google search parameters to make your searches more efficient. A common site people look towards for programming help is stackoverflow. If you want results from this site, try:

site:stackoverflow.com: {your question here}

Of course, this is barely scratching the surface of how you can learn, and this may not be the best way for you. The reason I recommend sticking with the very basics of JavaScript and learning from a problem-based approach is that JavaScript, as well as any other language, is a lot. At the end of the day though, you don't really need to learn about more intermediate concepts like prototypal inheritance, closures, binding, etc.

Some final thoughts/tips:

  • If you start running into problems with efficiency or the Google Apps Script quotas, remember that the most efficient Google Apps Script is using less of it; try using Apps Script for reading and writing data while doing manipulations with JavaScript.

  • Algorithms are your friend. If you find yourself manipulating a lot of data, consider what kind of manipulation you're trying to perform and research an algorithm that may fit your use case.

  • Keep it simple until you're comfortable. Don't try to solve problems in the most clever way you can. Most problems can be solved by throwing more code at it, for lack of a better way to word that. You're just getting started so you don't need everything to be perfect. Worry about opalization as you continue learning.

  • Lastly, and most important in my opinion, take this all with a grain of salt. There are many useful suggestions by the time I'm commenting this. Consider all of these suggestions as your options and spend some time vetting each one. Like marth141 said, "Asking here is a great place to learn" and this will be one of your most powerful tools.

Good luck! Feel free to reach out if you have any questions

2

u/marth141 Jul 20 '23

Asking here is a great place to learn. I too started with just sheet formulas then moved onto Google Apps Script.

Learning JavaScript would be great, however I highly recommend learning by doing.

Use the following link to learn about the urlfetchapp in Google Apps Script for getting information from outside sources. These are HTTP requests such as "GET" and "POST" where gets are self explanatory and posts are updates to gotten records.

https://developers.google.com/apps-script/reference/url-fetch/url-fetch-app

Here are also the docs to Google Spreadsheets itself

https://developers.google.com/apps-script/reference/spreadsheet

To navigate these docs, use the directory listings on the left.

Everything states what type it returns and you usually want to drill down on types from there. For example, spreadsheets usually goes...

"SpreadsheetApp > Spreadsheet Class > Sheet Class > Range Class > Values in Cells"

Which is expressed in code roughly like,

"SpreadsheetApp.getSpreadsheet().getSheet().getRange().getValues()"

I'm on a phone while writing. With the docs in hand though, go make your dreams. But realize that Google Apps Script is not perfect for everything. If you want to make rich and robust programs, you might need to get away from Google Apps Script.

Always feel free to ask in this community about problems and someone will definitely try to offer some help.

Cheers.

1

u/franxam Jul 20 '23

For example if you want to transfer your excel functions and all into Google sheets, you can first explore JavaScript by recording macros and looking into them, then adapting them. That will require you to document yourself for small stuffs first, bigger after. In the process, you'll be able to build functions from nothing by yourself and do more complex things (triggers, interacting with other apps from the Google suite...)

I won't say I'm a pro at JavaScript now (I discovered it when starting my first Google sheets macro), but I know enough to code what I need or find the information to do it

1

u/RemcoE33 Jul 20 '23
  1. Learn javascript. Apps script is javascript with google specific methods to interact with the google products. As example: You get the data from the sheet "in your script" aka in memory. You get this in a 2d array. Then you need javascript to filter/alter the data inside. You can use an interactive free course at https://www.freecodecamp.org/

  2. https://www.youtube.com/@ExcelGoogleSheets

  3. https://www.benlcollins.com/

  4. Try to solve questions here... This is what i did. It helped me a lot because you get problems outside you're own use cases.

1

u/knwpsk Jul 22 '23 edited Jul 22 '23

Be forewarned. Google provides no readable way to reuse your work from one spreadsheet to another, the way you can with Excel "personal macros". The closest answer Google has is that you should publish your code as a Google sheets add-on. The process for doing that is ridiculously complicated and I gave up.

I'm a big fan of Google sheets and I use it all the time, and I have numerous Google app scripts for various purposes.

This is the major weakness that Google workspace has, and drives me to continue using Excel for various things that I do repeatedly.

1

u/alvaroemur Aug 03 '23

I've had the same problem. I have lost track of where's my most recent library of reusable code.

What's your method for reusing code?

1

u/knwpsk Aug 08 '23

Well, a couple of answers:

  1. I still use Excel, because I have some great "personal macros" that I use constantly. Google Sheets foolishly doesn't support "personal macros" (usable across all files). Until they do, I'm still going to be an Excel user.

  2. I do have a lot of Google Apps Scripts, and many of them re-use the same functions. So I put those "utility" functions into a separate Apps Script project, and I call that my own "library". When I start a new Project, I link it to my "library" and then I can use those function calls without duplicating them in each new project. (This is NOT the same thing as a personal macro. This library is not related to spreadsheets at all. Rather, it's a bunch of functions that I use in various automated scripts. For example, I have one function called GetCurrentDateTimeYYYYMMDDHHMMSS(), and another called GetCurrentDateYYYYMMDD(), etc.)

1

u/alvaroemur Jan 14 '24

Yeah, that's basically what I'm doing too. Even the name is almost the same: utils.gs.

But this week I started experimenting with ChatGPT to convert some script I had to an add-on and it worked perfectly. You need to know some terminology first, so it's easier if you kind of study the situation until you feel you could solve it given enough time, and then comes ChatGPT to fill the gap for you. I'll see if this leads me to creating my own personal libraries to reuse in other projects.