SumByColor isn't working anymore

itaik

New Member
Joined
Feb 26, 2019
Messages
3
Hey all,
I added to an Excel file the following module:

Function SumByColor(CellColor As Range, rRange As Range)
Dim cSum As Long
Dim ColIndex As Integer
ColIndex = CellColor.Interior.ColorIndex
For Each cl In rRange
If cl.Interior.ColorIndex = ColIndex Then
cSum = WorksheetFunction.Sum(cl, cSum)
End If
Next cl
SumByColor = cSum
End Function


and it used to work until today and now all I get is ?NAME# value...
I am using Office 365 the latest version 16.0.11231.20164 32Bit and tried using other modules for SumByColor that are posted around the internet but all ends with the same results.
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
Are you sure that that code is in the same workbook, that you are trying to use it in?
 
Upvote 0
You'll also get that error if macros are disabled.
 
Upvote 0
yea, when I start to write the function I get an auto complete prompt for "SumByColor" and it used to work up until yesterday
 
Upvote 0
Oh god I feel embarrassed :eek:
apparently macros we disabled without any notification and once I set the file on a trusted location it worked!
Thank you very much for helping me get to this conclusion!
 
Upvote 0

Forum statistics

Threads
1,214,606
Messages
6,120,488
Members
448,967
Latest member
visheshkotha

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