Remove all define names in an Excel file

来源:互联网 发布:网络管理规范 编辑:程序博客网 时间:2024/06/02 02:51

When I copy a sheet of an Excel, promt a lot of message box about define names duplicate.

 

1. Open the Excel file.

2. Press "Alt + F11" (short cut) key to open  Visual Basic Editor.

3. Insert a Module by right click menu, paste the following code to the editor.

 

Sub DeleteAllNames()
    Dim nm As Name
    On Error Resume Next
    For Each nm In ThisWorkbook.Names
        nm.Delete
    Next nm
    On Error GoTo 0
End Sub

 

4. Press F5, then click run.

5. All of the define names is removed.

原创粉丝点击