简体   繁体   中英

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. 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. This makes Excel very slow especially when there are several workbooks opened.

Is there any other function that could replace INDIRECT() to lookup with dynamic sheet name?

  • Turn of automatic calculculations (strongly not advisable)
  • Build a UDF function, that is non-volatile by default:

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. See the screenshot in my answer to this question: Excel Vlookup with cell reference

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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