简体   繁体   English

Excel:替换INDIRECT()以动态引用工作表

[英]Excel: Replace INDIRECT() to dynamically refer to worksheets

I have a sheet with lots of INDIRECT() functions to pull data from other sheets in the same workbook. 我有一个带有许多INDIRECT()函数的工作表,用于从同一工作簿中的其他工作表中提取数据。 Something like 就像是

=INDIRECT(SheetName&"!A1")

I've realized that INDIRECT() is a volatile function so it re-calculates every time when any change is made in any workbook. 我已经意识到INDIRECT()是一个易失函数,因此每当在任何工作簿中进行任何更改时,它都会重新计算。 This makes Excel very slow especially when there are several workbooks opened. 这使Excel非常慢,尤其是在打开多个工作簿时。

Is there any other function that could replace INDIRECT() to lookup with dynamic sheet name? 还有其他函数可以替换INDIRECT()来使用动态工作表名称进行查找吗?

  • Turn of automatic calculculations (strongly not advisable) 轮流进行自动计算(强烈建议不要这样做)
  • Build a UDF function, that is non-volatile by default: 构建一个UDF函数,默认情况下它是非易失性的:

Public Function IndirectNotVolatile(sheetName As String, sheetRange As Range) as Variant
    Set IndirectNotVolatile = Worksheets(sheetName).Range(sheetRange.Address)
End Function

Lisa: You can use CHOOSE in association with a lookup table to replace INDIRECT. 丽莎:您可以将CHOOSE与查找表结合使用来替换INDIRECT。 See the screenshot in my answer to this question: Excel Vlookup with cell reference 请参阅我对以下问题的回答中的屏幕截图: Excel Vlookup,带有单元格引用

Also, check out my answer at Excel tables vs plain data where I give a bit of info on how you can address the root cause of your slow spreadsheet. 另外,在Excel表格和普通数据中查看我的答案,在其中我提供了一些有关如何解决电子表格运行缓慢的根本原因的信息。

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

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