Code stops after deleting a sheet

Gautham A

Board Regular
Joined
May 25, 2020
Messages
107
Office Version
  1. 2016
Platform
  1. Windows
I'm writing the following code
VBA Code:
Application.displayalerts= false
Sheets("L2_LookupTable"). delete
Sheets ("L2_Open_Incidents").Name="L2_LookupTable"
Sheets.add after:=Sheets ("Buttons")
ActiveSheet.name="L2_Open_Incidents"
Sheets("Buttons"). activate
Application.displayalerts=True

The code does not execute after 2nd line. It deletes L2_LookupTable sheet and does not execute after that. I'm not getting any error. Then if I press F8 it starts the code from first line
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
I have replicated this and it works.
Do you have any securities on the workbook? Are all the sheets visible?
In your code there are various words that aren't capitalising the first characters. I copied your code and it looks like this:

VBA Code:
Sub check()
Application.DisplayAlerts = False
Sheets("L2_LookupTable").Delete
Sheets("L2_Open_Incidents").Name = "L2_LookupTable"
Sheets.Add after:=Sheets("Buttons")
ActiveSheet.Name = "L2_Open_Incidents"
Sheets("Buttons").Activate
Application.DisplayAlerts = True
End Sub
 
Upvote 0
Hi Trevor,
Yes. All the sheets are visible. I typed the code on my phone. So only capital letters are missing. In vba I have written the code correctly.
 
Upvote 0

Forum statistics

Threads
1,214,948
Messages
6,122,420
Members
449,083
Latest member
Ava19

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top