Delete '_xlfn' named cells / range

nitrammada

Board Regular
Joined
Oct 10, 2018
Messages
78
Office Version
  1. 365
Platform
  1. Windows
Hello everyone,
I've searched through the forums and found some excellent code to delete hidden named cells and ranges but none the will delete named cells or ranges that start with an underscore eg '_xlfn'. I have 3 that I want to delete, namely _xlfn.IFERROR, _xlfn.SINGLE and _xlfn.XLOOKUP. They all refer to #NAME? Can anyone help me with some code to delete them?
Thanks in advance.
Adam
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
VBA Code:
Sub Delete_xlfn()
    Dim Found As Range, counter As Long
    Application.Calculation = xlManual
    Application.ScreenUpdating = False
    Set Found = ActiveSheet.UsedRange.Find("_xlfn", , xlFormulas, xlPart, 1, 1, 0)
    Do Until Found Is Nothing
        Found.ClearContents
        Set Found = ActiveSheet.UsedRange.FindNext(After:=Found)
        counter = counter + 1
        DoEvents
    Loop
    Application.Calculation = xlAutomatic
    Application.ScreenUpdating = True
    MsgBox counter & " cells deleted.", vbInformation, "Delete '_xlsm'"
End Sub
 
Upvote 0
Solution
VBA Code:
Sub Delete_xlfn()
    Dim Found As Range, counter As Long
    Application.Calculation = xlManual
    Application.ScreenUpdating = False
    Set Found = ActiveSheet.UsedRange.Find("_xlfn", , xlFormulas, xlPart, 1, 1, 0)
    Do Until Found Is Nothing
        Found.ClearContents
        Set Found = ActiveSheet.UsedRange.FindNext(After:=Found)
        counter = counter + 1
        DoEvents
    Loop
    Application.Calculation = xlAutomatic
    Application.ScreenUpdating = True
    MsgBox counter & " cells deleted.", vbInformation, "Delete '_xlsm'"
End Sub
Hi AlphaFrog, thanks so much for your response.
I ran the code but I still have these 3 named cells. I'm not sure, but could it be that I have formulas on veryhidden sheets? The custom software I'm using writes the data to separate sheets and then makes them veryhidden, so could it be that the formulas or, named cells (I'm not sure what causes these to occur) are residing on the veryhidden sheets as opposed to the active sheet?
 
Upvote 0
Ultimately deleting those names will have no effect if you have formulae that use the functions. Once you save, close & reopen xl they will be back.
They are there to provide some level of backwards compatibility without destroying the formulae.
 
Upvote 0
Ultimately deleting those names will have no effect if you have formulae that use the functions. Once you save, close & reopen xl they will be back.
They are there to provide some level of backwards compatibility without destroying the formulae.
OK, I understand, as you can tell, I wan't sure what they were for, and it makes sense what you are saying, thank you for explaining and thanks to AlphaFrog too as I have learnt how to delete formula that has them.
Cheers.
Adam
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,864
Messages
6,121,986
Members
449,058
Latest member
oculus

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