简体   繁体   English

检索 Google 表格公式的行号

[英]Retrieve Row Number for Google Sheets formula

I'm looking for some assistance on how to retrieve a row number in Google Sheets that will work with the functions below.我正在寻找有关如何在 Google 表格中检索行号的帮助,这些行号将与以下功能一起使用。

I have put together (probably badly?) two instructions in Google Sheets that work together to pull the last section of a string in a variable string of data with an ARRAYFORMULA , REGEXREPLACE , REGEXEXTRACT in one cell that provides the data for an IFERROR , REGEXEXTRACT , CONCANTENATE in another cell.我在 Google 表格中将两条指令放在一起(可能很糟糕?),它们一起工作以将字符串的最后一部分拉入可变数据字符串中,其中一个单元格中包含ARRAYFORMULAREGEXREPLACEREGEXEXTRACT ,该单元格为IFERRORREGEXEXTRACT提供数据, 在另一个单元CONCANTENATE中连接。

These are intended to be inserted into a Google Sheet through an automation trigger (Zapier) and are designed to call and extract the tracking code for items from various platforms (eBay, Etsy, Woocommerce, direct entry, etc.) so the process needs to be dynamic.这些旨在通过自动化触发器 (Zapier) 插入到 Google 表格中,旨在调用和提取来自各种平台(eBay、Etsy、Woocommerce、直接输入等)的项目跟踪代码,因此该过程需要充满活力。

I've been able to get the first set to work using the following as pasted into Google Sheets by Zapier.我已经能够使用 Zapier 粘贴到 Google 表格中的以下内容来让第一组工作。

=arrayformula(if(istext(P=P:ROW),{arrayformula(REGEXREPLACE(P=P:ROW,">.*","")),arrayformula(regexextract(P=P:ROW,"^.*>(.*)>.*$")),arrayformula(REGEXREPLACE(P=P:ROW,"^.*>",""))},))

This is able to call the ROW and update with each new line that is written in Google Sheets with each new Zap.这能够调用 ROW 并使用每个新 Zap 在 Google 表格中写入的每个新行进行更新。

The challenge is getting the next step to work automatically where currently the formula is written with the cell numbers hardcoded in, as:挑战在于让下一步自动工作,目前公式是用硬编码的单元格编号编写的,如:

=IFERROR(REGEXEXTRACT(CONCATENATE(P2,IF(T2="","","/"),T2),"[^\/]+$"),"")

With this being written in the current format the automation process fails as each new line added to Google Sheets by Zapier instructs Google Sheets to look for data in row 2 (per the hardcoded 2 ).由于这是以当前格式编写的,因此自动化过程失败,因为 Zapier 添加到 Google 表格的每一行都指示 Google 表格在第 2 行中查找数据(根据硬编码2 )。

This really needs to retrieve data in the 'same row' that it is written in.这确实需要在写入数据的“同一行”中检索数据。

A copy of the sheet can be found here: Google Sheets可以在此处找到该表的副本: Google 表格

  • Col P - Raw code fed from various ecommerce platforms Col P - 来自各种电子商务平台的原始代码
  • Col Q - First formula instruction pasted here by Zapier per the programmed Zap to create of a new line Col Q - Zapier 根据编程的 Zap 粘贴在这里的第一个公式指令,以创建一个新行
  • Col R - Intentionally blank Col R - 故意空白
  • Col S - Intentionally blank Col S - 故意空白
  • Col T - Intentionally blank Col T - 故意空白
  • Col U - Shipping Tracking Output pasted here by Zapier per the programmed Zap as a part of the same trigger to write to 'Col P' as above Col U - Shipping Tracking Output 由 Zapier 根据编程的 Zap 粘贴到此处,作为写入“Col P”的同一触发器的一部分,如上所述

If there is a better way to handle this I'd be happy to hear suggestions.如果有更好的方法来处理这个问题,我很乐意听取建议。 I could use Java as a Zap to run the process if the code is capable of doing the same thing.如果代码能够执行相同的操作,我可以使用 Java 作为 Zap 来运行该进程。

You can use Row() to get the row a formula is on, and INDEX to to reference a cell from a column.您可以使用Row()来获取公式所在的行,并使用INDEX来引用列中的单元格。 So change every instance of P2 to index(P:P,row())因此,将P2的每个实例更改为index(P:P,row())

Your formulas becomes你的公式变成

=arrayformula(if(istext(index(P:P,row())),{arrayformula(REGEXREPLACE(index(P:P,row()),">.*","")),arrayformula(regexextract(index(P:P,row()),"^.*>(.*)>.*$")),arrayformula(REGEXREPLACE(index(P:P,row()),"^.*>",""))},)) 

and

=IFERROR(REGEXEXTRACT(CONCATENATE(index(P:P,row()),IF(index(T:T,row())="","","/"),index(T:T,row())),"[^\/]+$"),"")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM