Need UDF to work from personal.xls NOT add-in for new Excel files

9tanstaafl9

Well-known Member
Joined
Mar 23, 2008
Messages
535
I have a Crystal Report that generates a poorly formated Excel worksheet every day. I have created a macro that the users can install onto their personal.xls so that once this worksheet is generated, they can simply open it and click CTRL-Shift-F will make it all look nice for them and have proper totals etc.

My problem is that I need a UDF to total only the items that are bold in parts of the worksheet.

I have created this UDF and it works fine when in my test workbook, but not when only in the personal.xls. I am new to UDFS and don't know if this is because I am lacking in knowledge, or if it just isn't possible.


My UDF is:

Code:
Function SumIfBold(MyRange As Range) As Double

    Dim cell As Range
    For Each cell In MyRange
        If cell.Font.Bold = True Then
            SumIfBold = SumIfBold + cell
        End If
    Next cell

End Function


Also, please reply in dummy-English. This is my first UDF and I don't really get them. I borrowed this from somewhere else, but it does the trick.

Thank you!
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
Me again. Sorry I didn't specify the Excel version. The worksheet is exported automatically to Excel 2003, but I can have the users save it into 2010 before running the macro if needed.
 
Upvote 0
There are several ways to do this. One way for instant gratification is to enter the function as

Code:
=personal.xls!SumIfBold(Whatever that range is)

Or, according to the individual user,

Code:
=personal.xlsb!SumIfBold(Whatever that range is)
 
Upvote 0
thank you for your reply! Unfortunately it didn't work. I tried it in both 2003 and 2010. When I type the formula, select the range, and hit enter for this: =personal.xls!SumIfBold(F10:F42) - it brings up the Update Values personal.xls window. I tried just making up a name but then it tells me file not found. Was I supposed to locate the personal.xls file and update it? It has already been saved.

What appears to happen on the spreadsheet itself is that the correct answer appears in the cell, but the aforementioned window opens up, and as soon as I exit that window I get a #Name? error in that same cell.
 
Last edited:
Upvote 0
THANK YOU! It did work. I must be an "individual user" because I needed to put the B at the end of personal.xls before it would work. I don't know why, but at this point I don't care. (Though if you wanted to tell me that would be great, because I do care, but I don't NEED to know.)
 
Upvote 0
"Personal" in versions of Excel through 2003 is an xls file. In 2007, several new file formats were introduced, and the default format for Personal became one of them (xlsb). An "individual user" of Excel 2007/2010/2013 could have either. I have an xls file because it's the same one I use for Excel 2003, which I still use occasionally.
 
Upvote 0

Forum statistics

Threads
1,220,965
Messages
6,157,119
Members
451,398
Latest member
rjsteward

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