Monday, January 23, 2012

UDF To return the formula written in a cell

If you want to extract the formula written on a cell . Try this UDF



Function know_formula(cl As Range) As String
    If cl.Cells.Count = 1 Then
        If cl.HasFormula Then
            know_formula = "'" & cl.Formula
        Else
            know_formula = "No Formula Found"
        End If
    End If
End Function


Download working file




Steps to Use
  • Copy the below code
  • Press Alt+F11 to open VBA editor
  • Paste it in any public module or module 1
  • For example you have entered any formula in Cell A1  and now  in cell B1 you want to know the formula typed in cell A1 . In cell B1 type =know_formula(A1) 

No comments:

Post a Comment

Import data from SQL

Macro to import data from SQL using ADO connection string: Sub Import_data_from_SQL() ' Tools -> References -> Microsoft Active...