问题描述
让我们说 sheet3.name =d
有没有办法在 sheet2
中的单元格中放入公式 = sum(sheet3!b:b)
其中 sheet3
正在替换为实际的sheet3名称?
我只能得到 = sum('d'!b:b)
到目前为止工作。
我可以使用VBA,但我很好奇如何在单元格中执行此操作,因此我不必每次都运行一个宏。 >
如果您可以使用将返回工作表名称的UDF 用户定义函数
函数SHEETNAME(number As Long)As String
SHEETNAME =表(数字).Name
结束函数
然后一个公式如
= SUM(INDIRECT(SHEETNAME(3)&!B:B))
将从表B中的列B返回总和。
SHEETNAME(number)
返回数字的工作表名称这是索引。
所以 Sheet(1)
返回Sheet1等
Lets say sheet3.name = "d"
Is there a way I could put in a cell on sheet2
the formula =sum(sheet3!b:b)
where sheet3
is being substituted with the actual sheet3 name?
I can only get =sum('d'!b:b)
to work so far.
I could use VBA for this probably but I'm curious how to do this in a cell so I don't have to run a macro each time.
If you can use a UDF User Defined Function that will return the sheet name
Function SHEETNAME(number As Long) As String
SHEETNAME = Sheets(number).Name
End Function
then a formula like
=SUM(INDIRECT(SHEETNAME(3) &"!B:B"))
will return the sum from column B on sheet 3.
SHEETNAME(number)
returns the sheet name of the number which is index.
So Sheet(1)
returns Sheet1, etc
这篇关于在单元格中引用数字而不是名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!