Hello there,
I am facing problem with excel crashing when I delete two sheets using macro as follows :
All I want to do is to delete two sheets named KrSh_H and UvArg_H and make fresh copies of two other sheets and name them same as deleted sheets.
I start with a sheet called "1Rx1" and refer to that name as Sheet(Arg). After deleting these two sheets I need to go to "1Rx1" and make a new copy of it with name "UvArg_H"
Similarly I need to delete the sheet 'KrSh_H' and make a copy of another sheet called 'KrSh_H_Templ' and then rename the new copy as 'KrSh_H'
But excel crashes every time.
Please help with code below
Sub Create_H_Sheets()
Dim ThSh
Arg = ActiveSheet.Name
Application.DisplayAlerts = False
ActiveWorkbook.Sheets("KrSh_H").Delete
ActiveWorkbook.Sheets("UvArg_H").Selec
ActiveSheet.Shapes("Btn1").Delete
ActiveSheet.Shapes("Btn2").Delete
ActiveWorkbook.Sheets("UvArg_H").Delete
ActiveWorkbook.Sheets("KrSh_H _Templ").Visible = True
ActiveWorkbook.Sheets(Arg).Select
Sheets(Arg).Copy after:=Sheets("KrSh_H _Templ")
ActiveSheet.Name = "UvArg_H"
ActiveWorkbook.Sheets("KrSh_H_Templ").Select
ActiveSheet.Copy after:=ActiveWorkbook.Sheets("KrSh_H_Templ")
ActiveSheet.Name = "KrSh_H"
ActiveWorkbook.Sheets("KrSh_H_Templ").Visible = False
Application.DisplayAlerts = True
End Sub
I am facing problem with excel crashing when I delete two sheets using macro as follows :
All I want to do is to delete two sheets named KrSh_H and UvArg_H and make fresh copies of two other sheets and name them same as deleted sheets.
I start with a sheet called "1Rx1" and refer to that name as Sheet(Arg). After deleting these two sheets I need to go to "1Rx1" and make a new copy of it with name "UvArg_H"
Similarly I need to delete the sheet 'KrSh_H' and make a copy of another sheet called 'KrSh_H_Templ' and then rename the new copy as 'KrSh_H'
But excel crashes every time.
Please help with code below
Sub Create_H_Sheets()
Dim ThSh
Arg = ActiveSheet.Name
Application.DisplayAlerts = False
ActiveWorkbook.Sheets("KrSh_H").Delete
ActiveWorkbook.Sheets("UvArg_H").Selec
ActiveSheet.Shapes("Btn1").Delete
ActiveSheet.Shapes("Btn2").Delete
ActiveWorkbook.Sheets("UvArg_H").Delete
ActiveWorkbook.Sheets("KrSh_H _Templ").Visible = True
ActiveWorkbook.Sheets(Arg).Select
Sheets(Arg).Copy after:=Sheets("KrSh_H _Templ")
ActiveSheet.Name = "UvArg_H"
ActiveWorkbook.Sheets("KrSh_H_Templ").Select
ActiveSheet.Copy after:=ActiveWorkbook.Sheets("KrSh_H_Templ")
ActiveSheet.Name = "KrSh_H"
ActiveWorkbook.Sheets("KrSh_H_Templ").Visible = False
Application.DisplayAlerts = True
End Sub