UDFs Won't Run from Add-In

Philip1957

Board Regular
Joined
Sep 30, 2014
Messages
185
Office Version
  1. 365
Platform
  1. Windows
Greetings,

This is my first attempt at a UDF. I have the following saved to MyFunctions.xlam and the add-in is active in all of my workbooks.

VBA Code:
Function CountCcolor(range_data As Range, criteria As Range) As Long
Dim datax As Range
Dim xcolor As Long

xcolor = criteria.Interior.ColorIndex

For Each datax In range_data
    If datax.Interior.ColorIndex = xcolor Then
        CountCcolor = CountCcolor + 1
    End If
    Next datax
End Function

The function shows up when I start typing in a cell ...

Capture2.PNG

... but it gives me a #NAME error and I don't understand why.

Capture.PNG


What am I doing wrong?

Any assistance would be greatly appreciated.

Thank you,
~ Phil
 

Attachments

  • Capture.PNG
    Capture.PNG
    12.4 KB · Views: 10

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
I suppose that issue is with reference of ranges.
Did you try:
Excel Formula:
=CountCcolor(Sheet1!B4:B103, Sheet1!E2)
 
Upvote 0
Thanks for the response.
Being more specific with the range didn't help. I still get #NAME?
 
Upvote 0
Do you have any #name errors in B4:B103?
 
Upvote 0
Do the other UDF's in the add-in work?
 
Upvote 0
Are macros enabled?

Is the module named the same name as the function?
 
Upvote 0
If you mean that the function & module share the same name, then change the name of the module.
 
Upvote 0

Forum statistics

Threads
1,223,912
Messages
6,175,348
Members
452,638
Latest member
Oluwabukunmi

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top