+ Reply to Thread
Results 1 to 5 of 5

Format Cell that hold a formula using a UDF and Conditional formatting

  1. #1
    Registered User
    Join Date
    04-06-2012
    Location
    LA, USA
    MS-Off Ver
    Excel 2010
    Posts
    6

    Question Format Cell that hold a formula using a UDF and Conditional formatting

    I am having trouble with the following UDF

    Function FormulaCell(Rge) As Boolean
    FormulaCell = Rge.HasFormula
    End Function

    Then I set the Conditional format = FormulaCell(A1)

    This method is available in many places on the inet but I cannot get it to work.
    I am using an .xlsm file with Macros enabled so it's not that

    Any thoughts?

    CliffB

  2. #2
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Format Cell that hold a formula using a UDF and Conditional formatting

    It works for me. Is the code for the UDF in a normal code module, not a Sheet's code module nor ThisWorkbook code module?
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  3. #3
    Registered User
    Join Date
    04-06-2012
    Location
    LA, USA
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Format Cell that hold a formula using a UDF and Conditional formatting

    Hi Mike

    Should it not work as long as the scope is Workbook?

    Cliff

  4. #4
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Format Cell that hold a formula using a UDF and Conditional formatting

    Try it in a normal module. Apparently it isn't working the way it is, where it is.

    As a general rule, I try to keep code out of an object's module unless it needs to be there.

    You also might try declaring the argument.
    Please Login or Register  to view this content.
    By the way,
    you should precede your lines of code with [code]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/code]
    When you see this in the edit window:
    [code]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/code]

    This is what it looks like on the board
    Please Login or Register  to view this content.
    Last edited by mikerickson; 04-09-2012 at 01:45 AM.

  5. #5
    Registered User
    Join Date
    04-06-2012
    Location
    LA, USA
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Format Cell that hold a formula using a UDF and Conditional formatting

    Thanks Mike

    This did not turn out to be the problem - I was thinking that the reference to A1 would mean the application to the first cell in the range - but I needed to put in the address of the current cell ie if you are in B7 then use the formula =FormulaCell(B7)

    Really this sounds stupid now that I write down what I did - I know you and everybody else have never made this type of mistake (sic) so I know it is only me being me.

    Anyway, your post seemed to enable my own thinking and I solved it as above

    CliffB

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1