Hello,
I'm dealing with a financial model with 150,000+ names (errors and links that can't be broken) and cannot open the name manager. In a separate thread, I came across the below macro which seems to help and I can run a handful of times before I get an error of either “subscript out of range error” or the name range / format is incorrect. Diving even deeper into the thread, I found the second line of code which just freezes up my excel "Excel (Not Responding)" and I think I will have to force quit. Does anyone have any tricks, suggestions, or macros that have worked for similar issues? Getting desperate here, so would appreciate any and all advice!
I'm dealing with a financial model with 150,000+ names (errors and links that can't be broken) and cannot open the name manager. In a separate thread, I came across the below macro which seems to help and I can run a handful of times before I get an error of either “subscript out of range error” or the name range / format is incorrect. Diving even deeper into the thread, I found the second line of code which just freezes up my excel "Excel (Not Responding)" and I think I will have to force quit. Does anyone have any tricks, suggestions, or macros that have worked for similar issues? Getting desperate here, so would appreciate any and all advice!
VBA Code:
Sub Delnames_00()
Dim i As Long
Dim LastCount As Long
Dim StartTime As Double
StartTime = Timer
LastCount = ActiveWorkbook.Names.Count
Debug.Print "Starting Count: " & ActiveWorkbook.Names.Count
Application.Calculation = xlCalculationManual
For i = 1 To ActiveWorkbook.Names.Count
ActiveWorkbook.Names(i).Delete
If i = 500 Then Exit For
Next i
Application.Calculation = xlCalculationAutomatic
MsgBox "Batch done - Removed: " & LastCount - ActiveWorkbook.Names.Count & " named ranges " & vbNewLine & vbNewLine _
& "Run Time: " & Format$((Timer - StartTime) / 86400, "h:mm:ss") & " h:mm:ss"
End Sub
Sub NoNames()
With ActiveWorkbook
Do While .Names.Count
.Names(.Names.Count).Delete
Loop
End With
End Sub
Last edited by a moderator: