Need some macro help!

Ron99

Active Member
Joined
Feb 10, 2010
Messages
347
Office Version
  1. 2016
Platform
  1. Windows
Hello,

I have recorded macro, the task which the code has to perform is as below:

I have data in sheet1, I cut the data from sheet1 and paste it in sheet 4, then I delete sheet1, when I delete I get a msg or pop up " Data may exist in sheet selected for deletion, to permanently delete the data, press delete" I press delete.

Now when I am running the data for the second time, I again get the same message,

All that I need is I do not want that message to come up, rather the code should delete it automatically without me pressing the button delete manually

my recorded code:

Range("A1").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Cut
Sheets("Sheet4").Select
Range("A1").Select
ActiveSheet.Paste
Sheets("Sheet1").Select
ActiveWindow.SelectedSheets.Delete
Range("A1").Select



Regards,
Ron
 

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
Try

Code:
With Sheets("Sheet1")
    .UsedRange.Copy Destination:=Sheets("Sheet4").Range("A1")
    Application.DisplayAlerts = False
    .Delete
    Application.DisplayAlerts = True
End With
Application.CutCopyMode = False
 
Upvote 0
Try:
Code:
Application.DisplayAlerts = False
Sheets("Sheet1").select
Range("A1").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Cut
Sheets("Sheet4").Select
ActiveSheet.Range("A1").Paste
Sheets("Sheet1").Delete
Range("A1").Select
Application.DisplayAlerts = True
 
Upvote 0
Hi,

One more query,

The task is I am inserting a worksheet by using macro recorder, the problem is when I had inserted a worksheet it was sheet7, then I renamed it as summary, when I executed the code, it dint work as it couldnt insert sheet7 again.

my recorded code:

Sheets("Sheet4").Select
Sheets.Add
Sheets("Sheet7").Select
Sheets("Sheet7").Name = "Summary"
Range("A1").Select


regards,
Ron
 
Upvote 0

Forum statistics

Threads
1,224,570
Messages
6,179,610
Members
452,931
Latest member
The Monk

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