?NAME# error

knittelmail

New Member
Joined
Jun 28, 2023
Messages
21
Office Version
  1. 365
Platform
  1. Windows
I have been using a function to determine if a cell contains bold text or not. It worked fine until a few days ago when Excel gave me a pop-up message that it was adding an @ to my formula because of some update. Both worked when I did the normal put the formula in the cell thing and now I get an ?NAME# error.


Rich (BB code):
Function BoldBold(rCell As Range) As Boolean
    IsBold = rCell.Font.Bold
End Function

or

Public Function BoldTry(cell As Range)

    Application.Volatile

    If cell.Font.Bold = True Then
        Isbold = True
    Else
        Isbold = False
    End If

End Function

What I am trying to do is use a formula to determine if a cell in column C is bold or not. Then, use the result in another formula. It doesn't seem to matter if I enter the UDF manually in each cell, copy and paste it, use autofill, or VBA to get the UDF into the cell. I get the same ?NAME# error. The formula as I am entering it in excel looks like this.
=BoldTry(C24)


Can anyone point me to what I am doing wrong?

Thank you in advance!
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
That error is usually caused by macros being disabled, the function being in a module with the same name, or being in a different workbook to the cell calling it.
 
Upvote 0
What is "Isbold"?
It looks like an undeclared variable that is being set, but not used anywhere.
I think where you have "Isbold" should be the name of your function, i.e.

Rich (BB code):
Function BoldBold(rCell As Range) As Boolean
    BoldBold = rCell.Font.Bold
End Function



Public Function BoldTry(cell As Range)

    Application.Volatile

    If cell.Font.Bold = True Then
        BoldTry = True
    Else
        BoldTry = False
    End If

End Function
 
Upvote 0
Ha! I didn't even read the code, on the basis that it 'used to work'...
Thanks to both Rory and Joe4!
I made the corrections to the code. It didn't work.
I checked and other macros still work. As best as I can tell: The workbook is macro enabled, the functions are in the VBA project where they are being called, and the module is named differently than the function itself..

Could it have anything to do with the cell being checked by the function having been copied and from another worksheet?

Again, thank you! I am too new to VBA to do much more than cobble things together and hope they work.
 
Upvote 0
What is the name of the VBA module where these functions are stored?
If they are stored in one of the Sheet module, they will not work on other sheets.
They should be stored in a General Module, not one the specific Sheet modules.
 
Upvote 0
Capture.JPG

This is what the Project window for me looks like.
The functions were originally written in PERSONAL.XLSB.
B1Formula
B2Formula
B3Formula
I tried several different versions of the function to see if that would help.
I had to make a copy of them in Lunch..... for them to show up there. (I don't know what it is called, but the little drop down window that appears when you start typing functions)
They do not appear when only present in PERSONAL.
 
Upvote 0
The "BoldBold" function did not work for me when I put it in the Personal Macro Workbook.
However, when I moved/copied it into a General Module (like "B1FormulaA") of the Workbook I was trying to use it in, it worked just fine.
 
Upvote 0
Turns out that Rory was mostly right. Macros are disabled - Sort of.
I can run a macro located in my Personal Macro Workbook, but not one located in a specific Workbook. Every time I tried anything not in the Personal Macro Workbook, I got an error saying macros were disabled. It didn't give me this error when trying to use functions though.

I ended up writing a loop to check the contents of the cells and put the value in a helper column. Then the helper column is copied to where I need it.
For curiosity's, here is the code part that made it work.

Rich (BB code):
Dim counter As Integer
For counter = 25 To 130


Cells(counter, 3).Activate

    
    Dim BoldTry As String
    If ActiveCell.Font.Bold = True Then
       BoldTry = True
    Else
       BoldTry = False
    End If
        
      Cells(counter, 30).Value = BoldTry

Next counter
'find and transfer sections to formula sheet

Cells.Find(What:="CREATE", After:=ActiveCell, LookIn:=xlValues, LookAt _
        :=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
        True, SearchFormat:=False).Activate
         Range(Selection, Selection.End(xlDown)).Select
         Selection.Offset(, 29).Select
        Selection.Copy Destination:=Worksheets("Formula Sheet").Range("W36")
'repeat repeat repeat
I would like to mark both of you as the person with the solution but not sure if I can. Thank you both very much! I could not have done it without your guidance.
 
Upvote 0

Forum statistics

Threads
1,222,902
Messages
6,168,938
Members
452,227
Latest member
sam1121

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