How to ignore “name XXX already exists” messages when moving sheets in excel VBA

佐手、 提交于 2020-06-29 11:07:20

问题


I am trying to copy from one workbook to another but get a message as I move the sheet that a name already exists. is there a way to automatically ignore this message?

The message is: is:

the code for the copy

CurrentWorkBook.Sheets(Array("Compliance - learning")).Copy Before:=ActiveWorkbook.Sheets(1)

回答1:


I think you are looking for

Application.DisplayAlerts = False
    CurrentWorkBook.Sheets(Array("Compliance - learning")).Copy Before:=ActiveWorkbook.Sheets(1)
Application.DisplayAlerts = True


来源:https://stackoverflow.com/questions/40134749/how-to-ignore-name-xxx-already-exists-messages-when-moving-sheets-in-excel-vba

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!