Question : VBA function works on Excel 2007 file locally but not when in SharePoint 2007

I have an Excel worksheet where one cell calculates the specific color quantity, a COUNT function, not a SUM function. If a certain number of cells in a column are highlighted yellow I reference a cell with yellow in it and the function counts how many cells are highlighted yellow in the cell range I enter.  Everything works as expected if the Excel file is stored locally on a desktop machine or even if it is on a file share.  However, when I upload the file to a SharePoint 2007 document library and you check out the file to edit or view, the VBA Module produces a #NAME? error.  Also, any local non-customized function like a straight forward count or sum of a cell range works fine while the file is on SharePoint,  It seems to only break when you have any custom VBA attached.  Is there a way to make the VBA work if the associated file is on SharePoint?
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
Function CountColor(rColorRange As Range, rColorIndex As Range) As Long
    Dim rCell As Range 'range for  loop.
    Dim lColor As Long 'Index of the cells color we want to  count.
    Dim lColorCount As Long 'Counter
     
    lColorCount = 0 'Initialize counter
    lColor = rColorIndex.Interior.ColorIndex 'Set color to count
     
     'Loop through each cell in the range
    For Each rCell In rColorRange
        If rCell.Interior.ColorIndex = lColor Then lColorCount = lColorCount + 1
    Next rCell
     
     'Return count to function
    CountColor = lColorCount
End Function

Answer : VBA function works on Excel 2007 file locally but not when in SharePoint 2007

Russ,

To make it work when you upload it to sharepoint list, you need to create sharedservices. In sharedservices you need to create your function/assembly and add it to User-defined function assemblies  
under Excel Services Settings.
Random Solutions  
 
programming4us programming4us