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
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

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
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,224,846
Messages
6,181,305
Members
453,031
Latest member
Chris_1

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