loop through names and delete those not matching specified pattern

后端 未结 1 1204
攒了一身酷
攒了一身酷 2021-01-17 00:17

I have a Excel workbook in which I import sheets from several other workbooks and then merge the data from these into an \"overview\" sheet. I am fairly new to vba so this t

相关标签:
1条回答
  • 2021-01-17 01:02

    You need to use the namelocal property of the name object.

    Try this:

    Sub DeleteNames()
    
    Dim myName As Name
    
     For Each myName In ThisWorkbook.Names
    
      If myName.NameLocal <> "Tower" And myName.NameLocal <> "Bird" Then
        myName.Delete
      End If
    
     Next
    End Sub
    
    0 讨论(0)
提交回复
热议问题