• Cell Formula


    Is there a VB equivalent to the following XL formula?
    Formula = CELL(info_type,reference).
    I’m trying to determine if the active cell is a label or value.

    Viewing 1 reply thread
    • #508504


      Any function can be coded as a worksheet functiion:
      answer = Application.WorksheetFunction.CELL(info_type,reference)

      I’m not that’s the best way to do it- but I’m not sure what you mean by “a label or value”. You can look at things like cells(i,j).value or cells(i,j).formula- I don’t know if that’s going to achieve what you want


    • #508505

      I would use the HasFormula Property. Quote below from Microsoft Help.

      “True if all cells in the range contain formulas; False if none of the cells in the range contains a formula; Null otherwise. Read-only Variant.”

      The sample code from help, slightly modified, with no error checking, gives the general idea how the property works.

      Sub tst()
          Set rr = Application.InputBox(prompt:="Select a range on this worksheet", Type:=8)
          If rr.HasFormula = True Then
              MsgBox "Cell(s) in the selection contains a formula"
              MsgBox "No Formula Found"
          End If
      End Sub


    Viewing 1 reply thread
    Reply To: Cell Formula

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: