Forum Discussion
Rudrabhadra
Oct 31, 2022Brass Contributor
Named range delete VBA
While trying to combine different workbooks in a folder to worksheets in a workbook. (which I have VBA code). while running the code a message is displayed that "The name "xxxxx" already exists Clic...
PeterBartholomew1
Oct 31, 2022Silver Contributor
Broadly speaking you need a further loop for each file to run through its Name Collection.
For Each definedName In fnameCurFile.Names
definedName.Delete
Bear in mind that this could destroy every formula in your new workbook (assuming there are formulas and that they use the defined Names). To bring Names across coherently, they all need to be scoped to the Worksheet rather than using global Workbook-scoped Names.