UDFs Won't Run from Add-In

Philip1957

Board Regular
Joined
Sep 30, 2014
Messages
182
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: 8
I cleared the cells where I'm calling out this UDF.
I changed the name of the module so that it is different from the name of the function.
I then used the UDF in my workbook and the counts came out correct. So far, so good.
Then I saved & closed the workbook, reopened it, and found the correct results had become #NAME? errors again. Calculate Now didn't change a thing.
This is just bonkers.
 
Upvote 0

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Maybe a stupid question, but did you save the add-in?
 
Upvote 0
Yes, the add-in is saved.

Yes, macros are enabled. I'm trying to use the UDF in an xlsm workbook.
 
Upvote 0

Forum statistics

Threads
1,214,904
Messages
6,122,169
Members
449,070
Latest member
webster33

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