getformula UDF
I have the following code as a UDF which allows you to display the formula
for a referenced cell: Function GetFormula(Cell As Range) As String GetFormula = Cell.Formula End Function So, if A1 has as its formula =2+3, and I enter into B1 =getformula(A1), =2+3 is shown. All well and good. However, I have a number of cells formatted as times (8:30AM, etc.) and, when I use =getformula(cell) on them, strange numbers return: .354166666... Ideas? Does this have to do with 8:30AM being 35.4% of a complete day? |
getformula UDF
Actually, for anyone's reference, my supposition below is true, as when I
changed the time to 12:00 PM the returned value was .5 and 12 hours is .5 of 24... Weird. Dave "Dave F" wrote: I have the following code as a UDF which allows you to display the formula for a referenced cell: Function GetFormula(Cell As Range) As String GetFormula = Cell.Formula End Function So, if A1 has as its formula =2+3, and I enter into B1 =getformula(A1), =2+3 is shown. All well and good. However, I have a number of cells formatted as times (8:30AM, etc.) and, when I use =getformula(cell) on them, strange numbers return: .354166666... Ideas? Does this have to do with 8:30AM being 35.4% of a complete day? |
getformula UDF
Yep, that sums it up. Dates and times are held as numbers relative to a
reference point. 08:30 is just over a third of the way through the day, so, 0.354... It's not a formula, it's a value. Perhaps you need to get your function to check for formulae ? Regards Trevor "Dave F" wrote in message ... I have the following code as a UDF which allows you to display the formula for a referenced cell: Function GetFormula(Cell As Range) As String GetFormula = Cell.Formula End Function So, if A1 has as its formula =2+3, and I enter into B1 =getformula(A1), =2+3 is shown. All well and good. However, I have a number of cells formatted as times (8:30AM, etc.) and, when I use =getformula(cell) on them, strange numbers return: .354166666... Ideas? Does this have to do with 8:30AM being 35.4% of a complete day? |
getformula UDF
Try
Function GetFormula(Cell As Range) As String If Cell.hasFormula Then GetFormula = Cell.Formula Else GetFormula = "" End If End Function -- HTH Bob Phillips (replace somewhere in email address with gmail if mailing direct) "Dave F" wrote in message ... I have the following code as a UDF which allows you to display the formula for a referenced cell: Function GetFormula(Cell As Range) As String GetFormula = Cell.Formula End Function So, if A1 has as its formula =2+3, and I enter into B1 =getformula(A1), =2+3 is shown. All well and good. However, I have a number of cells formatted as times (8:30AM, etc.) and, when I use =getformula(cell) on them, strange numbers return: ..354166666... Ideas? Does this have to do with 8:30AM being 35.4% of a complete day? |
All times are GMT +1. The time now is 05:49 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com