How do I get my formula to always reference to the last sheet?

前端 未结 2 683
忘了有多久
忘了有多久 2020-12-16 21:39

I currently have 2 worksheets in my excel file.

The first sheet is known as the Summary page, which displays an summary result of the second sheet.

The secon

相关标签:
2条回答
  • 2020-12-16 22:02

    You can use the XLM/Range Name workaround for this and not VBA if you prefer

    1. Define a range name, wshNames to hold the array of sheet names
      =RIGHT(GET.WORKBOOK(1),LEN(GET.WORKBOOK(1))-FIND("]",GET.WORKBOOK(1)))
      Uses David Hager's technique
    2. Use this Excel formula to extract the last sheet name from the array of sheet names
      =INDEX(wshNames,COUNTA(wshNames)+RAND()*0)

    This formula says look at all the sheets, then return the last (using the COUNTA). The RAND()*0) portion ensures that the formula is volatile and updates when Excel does

    If you do use VBA you will need to ensure your GETLASTWSNAME function is volatile, i.e. it gets updated when changes occur.

    enter image description here

    0 讨论(0)
  • 2020-12-16 22:25

    =COUNTIF(INDIRECT(GETLASTWSNAME() & "!A2:A7"),"Apple")

    0 讨论(0)
提交回复
热议问题