Add Column in Google Sheets module instead of Add Row

Hi all,

I’m looking to output to a Google Sheet but rather than having the module Add Row I’d like it to Add Column. Unfortunately, I don’t see any options for that. My hail mary attempt was to have it spit out three different comma separated inputs to columns via add row but everything just appeared in one cell instead of broken out. Is there any way to accomplish this?

Hi @Sean_Baptiste,

For this, you’ll likely need to use Google Sheets Make an API Call and figure out from the Google Sheets API reference what call needs to be made.

Likely this method would be used to write the values: Method: spreadsheets.values.update  |  Google Sheets  |  Google for Developers

If you don’t know exactly which column will need to be written to, then determine the last column in the used range, then write your data starting at the next column.
I don’t really know the best practice to determine this, or if there’s already a function for it like there is in Excel, but if I find it I’ll respond again!

3 Likes

I appreciate it! I’ll try that out and see if it works. This is definitely a bit of an edge case.

So here’s one approach to get the next available column.

Google Sheets Make an API Call configured like this:
image

Replace <spreadsheet_id> with your actual spreadsheet ID and Sheet1 with the name of the sheet you’re using.
That will get you all of Row 1.

The API won’t return empty rows and it will return an array of values from that row.
For my example, that’s:
image

Length of array is 3 meaning 3 is the last used column, so start writing on column 4.

Still need to make assumptions, such as you will always have data in the first row of every column, otherwise you run the risk of overwriting a column. To prevent this, if you can, try to use a placeholder in a cell to indicate it should be blank, like a 0.

Also, when writing to cell, need to use R1C1 notation rather than A1.
If you want to use A1 notation, you’ll have to figure out which letter corresponds to the column number.

Hope that helps!

4 Likes