SumColour Macro works in 2003 but not 2007

hvaleagues

New Member
Joined
Sep 25, 2009
Messages
9
I have a macro that allows me to sum cells based on the shading of the cell. This works wonderfully in 2003, but when I send the file to someone using 2007 (ie my boss), the macro doesn't work and produces a ton of #NAME? errors, instead of giving him the information he needs. Here is the code:

Code:
Function SumColoured(oRange As Range, lColorIndex As Variant) As Variant
    Dim oCell As Range
    Dim dSum As Double
    Application.Volatile
    For Each oCell In oRange
        If oCell.Interior.ColorIndex = lColorIndex Then
            dSum = dSum + Val(oCell.Value)
        End If
    Next
    SumColoured = dSum
End Function
Is there something I can change in here to make it work on 2007 (and 2010).

Any help would be greatly appreciated.
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
It seems that Your boss must change macro security settings in Excel to "Enable all macros"
regards, PH
 
Upvote 0
It seems that Your boss must change macro security settings in Excel to "Enable all macros"
You really don't want your boss to do that.

Excel Options > Trust Center > Trust Center Settings > Macro Settings, tick Disable all macros with notification.

Then teach her to look for the security warning below the ribbon, and enable macros only when the workbook comes from someone she trusts, like you.
 
Upvote 0
Thanks. I was initially told that he was enabling macros, but upon further questioning he wasn't. I had him change his settings per shg's suggestions.

Thanks again!
 
Upvote 0

Forum statistics

Threads
1,224,583
Messages
6,179,673
Members
452,937
Latest member
Bhg1984

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