문제

I'm currently trying to delete a worksheet and auto create a new worksheet with the same name.

I'm using the below code. However, when i run the code the windows pop up appears asking me to confirm deletion, i want to prevent this and just delete and replace with a new sheet. I want to avoid Send-keys for this.

ThisWorkbook.Sheets("Process Map").delete
ThisWorkbook.Sheets.Add.Name = "Process Map"
도움이 되었습니까?

해결책

Try setting the DisplayAlerts to False (then back to true if that is what you want as the default setting.

Application.DisplayAlerts = False
On Error Resume Next 
ThisWorkBook.Sheets("Process Map").Delete 
On Error Goto 0 
Application.DisplayAlerts = True
ThisWorkbook.Sheets.Add.Name = "Process Map" 

Or without error handling:

Application.DisplayAlerts = False
ThisWorkBook.Sheets("Process Map").Delete 
Application.DisplayAlerts = True
ThisWorkbook.Sheets.Add.Name = "Process Map" 
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top