帮我优化以下公式 =IFERROR(VLOOKUP(LOWER(AL$8),INDIRECT("B"&MATCH(":BEGIN",$B:$B,0)+$AK10*(COUNTA($B:$B)/IF(COUNTIF($B:$B,":BEGIN")=COUNTIF($B:$B,":END"),COUNTIF($B:$B,":BEGIN"),"原始数据错误"))-(COUNTA($B:$B)/IF(COUNTIF($B:$B,":BEGIN")=COUNTIF($B:$B,":END"),COUNTIF($B:$B,":BEGIN"),"原始数据错误"))&":C"&MATCH(":END",$B:$B,0)+$AK10*(COUNTA($B:$B)/IF(COUNTIF($B:$B,":BEGIN")=COUNTIF($B:$B,":END"),COUNTIF($B:$B,":BEGIN"),"原始数据错误"))),2,FALSE),"无数据")
时间: 2023-06-18 22:06:57 浏览: 433
这个公式比较复杂,可以考虑拆分成多个较小的部分,以便更好地理解和维护。以下是优化后的公式:
1. 首先,将常量抽取出来,以便在后面的计算中重复使用:
```
COUNTA_B = COUNTA($B:$B)
COUNTIF_BEGIN = COUNTIF($B:$B,":BEGIN")
COUNTIF_END = COUNTIF($B:$B,":END")
IF_ERROR = "无数据"
INDIRECT_START = "B"&MATCH(":BEGIN",$B:$B,0)
INDIRECT_END = ":C"&MATCH(":END",$B:$B,0)
```
2. 接下来,将公式中的重复计算抽取出来,以便减少计算次数:
```
OFFSET_FACTOR = COUNTA_B / IF(COUNTIF_BEGIN = COUNTIF_END, COUNTIF_BEGIN, "原始数据错误")
OFFSET_START = AK10 * OFFSET_FACTOR
OFFSET_END = OFFSET_START - COUNTA_B / IF(COUNTIF_BEGIN = COUNTIF_END, COUNTIF_BEGIN, "原始数据错误")
```
3. 将公式中的逻辑判断抽取出来,以便更好地理解和维护:
```
IF_ERROR_VLOOKUP = IFERROR(
VLOOKUP(
LOWER(AL$8),
INDIRECT(
INDIRECT_START + OFFSET_START & INDIRECT_END + OFFSET_END
),
2,
FALSE
),
IF_ERROR
)
```
4. 将所有的部分组合起来,得到最终的公式:
```
=IF_ERROR_VLOOKUP
```
总体来说,这个优化后的公式更易于理解和维护,同时还可以减少计算次数,提高性能。
阅读全文