Results 1 to 14 of 14

Excel 2016-Custom Function not available to use in-cell

Threaded View

  1. #1
    Registered User
    Join Date
    01-24-2018
    Location
    UK
    MS-Off Ver
    2010
    Posts
    6

    Excel 2016-Custom Function not available to use in-cell

    I am trying to create a custom function (to count the number of cells in a range that have font color = red). I have the code to do this, so that's not my problem. My problem is that having created the function, saved the VBA screen when I go back to the spreadsheet and type "=countcolorif(" the function is just not in the list and if I persist in trying to complete the syntax, I just get "#NAME" error. What's going on?

    I googled this a lot and watched YouTube videos but the function still refuses to show in-cell. It is in the user-defined list when I select "Insert Function" on the Formulas ribbon but I do not want to access it from there. I just want to type into the cell itself.

    1. Excel version is Microsoft Office pro 2016
    2. The function is prefaced with "Public"
    3. The vba is located in a new module not in "ThisWorkbook" area.

    Code is:

    Public Function CountColorIf(rSample As Range, rArea As Range) As Long
        Dim rAreaCell As Range
        Dim lMatchColor As Long
        Dim lCounter As Long
    
        lMatchColor = rSample.Interior.Color
        For Each rAreaCell In rArea
            If rAreaCell.Interior.Color = lMatchColor Then
                lCounter = lCounter + 1
            End If
        Next rAreaCell
        CountColorIf = lCounter
    End Function
    What on earth am I doing wrong?

    Thanks
    Last edited by Pepe Le Mokko; 02-05-2019 at 07:37 AM. Reason: Added code tags

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. How to pass named arguments to custom (UDF) functions in Excel 2016
    By Cornan in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-18-2019, 11:12 AM
  2. [SOLVED] Excel 2016 Custom formatting 18/04 YY/MM
    By clairh2011 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 04-04-2018, 10:04 AM
  3. Replies: 1
    Last Post: 09-18-2017, 08:27 AM
  4. Custom Globe (3d Maps Excel 2016)
    By Skagyeix in forum Excel General
    Replies: 0
    Last Post: 04-05-2017, 06:04 AM
  5. Had custom toolbar in older Excel for Mac, seeking similar functionality in Excel 2016
    By ianpage in forum For Other Platforms(Mac, Google Docs, Mobile OS etc)
    Replies: 2
    Last Post: 05-13-2016, 11:06 AM
  6. Why won't Excel 2016 display my custom ribbon?
    By rkjudy in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-05-2015, 04:20 PM
  7. How do you insert a custom function into an excel cell using vba?
    By 111StepsAhead in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-06-2011, 10:55 AM

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