Hua
Hua

Reputation: 31

Copying formula referencing a different sheet with updated cell references

This question is similar to this one, except that the formula I am copying doesn't reference the cells in the same sheet, but reference cells in a different sheet.

For example, I have sheet 1 and 2 in a Google sheet file. For sheet 1:

A1: ='sheet 2'!A1 - 'sheet 2'!A2

B1: =' '

I would like to copy A1's formula to B1 so it looks like:

B1: ='sheet 2'!B1 - 'sheet 2'!B2

Obviously I can do this manually by dragging the + sign at the bottom right corner of A1 down to B1 in sheet 1. But how do I do this with sheet API?

I've tried the top rated solution for this question, and it works if the formula references cells in the sheet 1. If the formula references cells in sheet 2, it does copy the formula but won't update the cell reference... the result would look like:

B1: ='sheet 2'!A1 - 'sheet 2'!A2

Any suggestions?

Upvotes: 0

Views: 155

Answers (1)

TheMaster
TheMaster

Reputation: 50826

You can use autofill request to simulate autofill(i.e., dragging the + sign at the bottom right corner of A1 down)

Upvotes: 1

Related Questions