Macro to delete Column

  • Thread starter Thread starter Kim
  • Start date Start date
K

Kim

Hi all,

I tried to record a macro to delete some column. Here is what I got but when
I run the macro it didn't performe correctly:

Sub Selection()

Sheets("Negotiation Tool Report").Select
Sheets("Negotiation Tool Report").Copy After:=Sheets(1)
Sheets("Negotiation Tool Report (2)").Select
Sheets("Negotiation Tool Report (2)").Name = "Selection"
Columns("A:A").Select
ActiveCell.Delete Shift:=xlToLeft
Columns("M:Z").Select
Selection.Delete Shift:=xlToLeft
Sheets.Add After:=Sheets(Sheets.Count)

When I run it keep come out as error on Selection.Delete. I've tried
changing Selection to ActiveCell but the result is that it select the cell
but didn't delete them.

Can anyone help?

Thanks.
Kim
 
Try the below

Dim ws As Worksheet
Set ws = Sheets("Negotiation Tool Report")

ws.Copy After:=Sheets(1)
Set ws = ActiveSheet
ws.Name = "Selection"

ws.Columns("A").Delete
ws.Columns("M:Z").Delete
Sheets.Add After:=Sheets(Sheets.Count)

If this post helps click Yes
 
Back
Top