Results 1 to 3 of 3

Thread: Cell Formula

  1. #1
    Silver Lounger
    Join Date
    Dec 2000
    Location
    California, USA
    Posts
    1,758
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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.

  2. #2
    Platinum Lounger
    Join Date
    Dec 2000
    Location
    Queanbeyan, New South Wales, Australia
    Posts
    3,730
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Cell Formula

    Hi,

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

    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

    Geoff
    Subway Belconnen- home of the Signboard to make you smile. Get (almost) daily updates- follow SubwayBelconnen on Twitter.

  3. #3
    2 Star Lounger
    Join Date
    Dec 2000
    Posts
    188
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Cell Formula

    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.

    <pre>Sub tst()
    Worksheets("Sheet1").Activate
    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"
    Else
    MsgBox "No Formula Found"
    End If
    End Sub
    </pre>


    HTH

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •