Thursday, May 16, 2019

How to Automate Google Sheets with Macros

I've been using Google Sheets in preference to Microsoft Excel for some personal files. For what I need, the simplicity of Google Sheets compared to Excel makes it the better choice. But I have one spreadsheet that I was considering using Excel for. I want hide a bunch of columns in an export file from LibraryThing and I would have to do it every time I create a new export file. So I was going to try to write an Excel macro, which I have not done before. (I know how to write Word macros, but have never done it in Excel).

However, it turns out that Google Sheets has a macro recorder, which I didn't know before reading this article.
When you record a macro in Google Sheets, it automatically creates an Apps Script with all the code to replicate your actions for you. This means you can create complex macros without knowing how to write code. The next time you run it, Sheets will do everything you did when you recorded the macro. Essentially, you’re teaching Google Sheets how to manipulate a document to your liking with a single command.
If I needed to do anything complex with a spreadsheet macro, I probably would use Excel. I'm much more comfortable with Microsoft's VBA than Google's AppScript. But it's nice to have the recording capability in Sheets to automate simple tasks.

Now, if Google would give us that capability in Docs, I'd be much more inclined to use Docs instead of Word.

No comments: