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?
To clarify:
Is something like this possible?
Usually you type =A1 for referring to the cell A1 in Excel. But instead, there is also another method: You could use the INDIRECT formula. The formula returns the reference given in a text. So instead of directly linking to =A1, you could say =INDIRECT(“A1”).
Text strings are also created in Excel and Google Sheets by entering an apostrophe ( ' ) as the first character of data. The apostrophe is not visible in the cell but forces the program to interpret whatever numbers or symbols are entered after the apostrophe as text.
In fact, Excel stores datetime
as a number
, so you have to explicitly set format of the cell to see the proper value.
You may want to use TEXT
function, but anyway, you have to specify format
of output string:
=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:
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With