[英]Reference cell value as string in Excel
In Excel, if the cell A1 has some value that gets formatted in a specific way, is there a way for cell B1 to reference the string displayed in A1? 在Excel中,如果单元格A1有一些以特定方式格式化的值,单元格B1是否有方法引用A1中显示的字符串?
To clarify: 澄清:
Is something like this possible? 这样的事情可能吗?
In fact, Excel stores datetime
as a number
, so you have to explicitly set format of the cell to see the proper value. 实际上,Excel将
datetime
存储为number
,因此您必须显式设置单元格的格式以查看正确的值。
You may want to use TEXT
function, but anyway, you have to specify format
of output string: 您可能想要使用
TEXT
函数,但无论如何,您必须指定输出字符串的format
:
=TEXT(A1,"hh:mm:ss")
Another option is to write your own VBA function, which can convert a value of a cell based on it's format: 另一种选择是编写自己的VBA函数,它可以根据格式转换单元格的值:
Public Function GetString(ByVal cell As Range) As String
GetString = Format(cell, cell.NumberFormat)
End Function
This will give you a result based on source cell's format 这将根据源单元格的格式给出结果
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.