Results 1 to 7 of 7

Thread: Breaking the rules for UDF's (User Defined Functions)

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #5
    Forum Guru Rick Rothstein's Avatar
    Join Date
    Feb 2012
    Posts
    662
    Rep Power
    15
    Quote Originally Posted by Marcelo Branco View Post
    Rick,

    This worked for me

    Code:
    Sub TooCool(InCell As Range, PushTo As Range)
      PushTo.Value = "The square of " & InCell.Value & " (in " & _
                     InCell.Address(0, 0) & ") is " & InCell.Value ^ 2 & "."
        PushTo.Interior.Color = vbYellow
        PushTo.Font.Color = vbRed
    End Sub
    
    Function DoCool(Rng As Range) As String
      If Rng.Value < 0 Then
        DoCool = "Number in " & Rng.Address(0, 0) & " is less than zero."
      Else
        DoCool = "Number in " & Rng.Address(0, 0) & " is greater than, or equal to, zero."
      End If
      Evaluate "HYPERLINK(TooCool(" & Rng.Address & ",J3))"
    End Function
    M.
    You are right, it does work... in XL2007 and above! I do all my testing in XL2003 figuring if it works there, it will work anywhere. Well, that appears to not be true... the colors do not work in XL2003, but it does work in XL2007 and later. Thanks for trying it out, although I am not sure why it did not occur to me to so myself.

    EDIT NOTE: I just tried making the font bold and italicized... didn't work.
    Last edited by Rick Rothstein; 10-17-2013 at 10:13 PM.

Similar Threads

  1. UDF (user defined function) replacement for Excel's DATEDIF function
    By Rick Rothstein in forum Rick Rothstein's Corner
    Replies: 21
    Last Post: 03-07-2015, 09:47 PM
  2. Color Functions In Excel
    By Admin in forum Download Center
    Replies: 2
    Last Post: 10-24-2013, 11:44 AM
  3. Creating Powerpoint Slides: Rules
    By Transformer in forum Powerpoint Help
    Replies: 0
    Last Post: 05-17-2013, 08:41 PM
  4. Replies: 2
    Last Post: 05-14-2013, 01:02 AM
  5. Excel Macro to Sort Data if a value changes in defined range
    By Rajesh Kr Joshi in forum Excel Help
    Replies: 4
    Last Post: 09-05-2012, 10:31 AM

Posting Permissions

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