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.
 

Some videos you may like

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.

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
46,530
Office Version
  1. 365
Platform
  1. Windows
Are you sure that that code is in the same workbook, that you are trying to use it in?
 

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
35,517
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2010
Platform
  1. Windows
  2. MacOS
You'll also get that error if macros are disabled.
 

itaik

New Member
Joined
Feb 26, 2019
Messages
3
yea, when I start to write the function I get an auto complete prompt for "SumByColor" and it used to work up until yesterday
 

itaik

New Member
Joined
Feb 26, 2019
Messages
3
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!
 

Watch MrExcel Video

Forum statistics

Threads
1,109,331
Messages
5,528,052
Members
409,800
Latest member
camronmartin

This Week's Hot Topics

Top