首页 > 解决方案 > Auto-fill custom function

问题描述

So in my Google Sheet I have a custom function that just gets values from a json file. I'm trying to auto-fill 1 value in this function, but it doesn't work. I'm trying to achieve this:

=IMPORTJSON("example.json","1/value")
=IMPORTJSON("example.json","2/value")
=IMPORTJSON("example.json","3/value")

I would want it to autocomplete to 3,4,5 etc but it just repeats 1,2,3. I tried to put 1,2,3 in a separate cell then auto-fill those cells and just reference the cell in the function, but that doesn't work. Help much appreciated.

标签: google-apps-scriptgoogle-sheetscustom-function

解决方案


使用 ROW() 和 & 运算符

=IMPORTJSON("example.json",ROW()&"/value")

ROW() 返回行号。如果您需要偏移量,假设您需要=IMPORTJSON("example.json","1/value")第 2 行,然后使用

=IMPORTJSON("example.json",(ROW()-1)&"/value")

推荐阅读