MrKowz
Well-known Member
- Joined
- Jun 30, 2008
- Messages
- 6,653
- Office Version
-
- 365
- 2016
- Platform
-
- Windows
Ok, another problem. I need to delete very specific columns every month from the reports I open, but when I run the macro that is supposed to do that, it deletes almost everything from the report, even the columns I did not tell the macro to select.
Do I need to add in something like "Range("A1").Select" in between each of the Selection.Delete Shift:=xlToLeft?
The reason this code looks so nasty is because when I was selecting multiple columns with something like "Columns("A:Z,AB:AC,AF:AF").Select, I was getting an overlap error.
Do I need to add in something like "Range("A1").Select" in between each of the Selection.Delete Shift:=xlToLeft?
Code:
Columns("C:P").Select
Selection.Delete Shift:=xlToLeft
Columns("C:D").Select
Selection.Delete Shift:=xlToLeft
Columns("D:D").Select
Selection.Delete Shift:=xlToLeft
Columns("E:S").Select
Selection.Delete Shift:=xlToLeft
Columns("F:F").Select
Selection.Delete Shift:=xlToLeft
Columns("G:H").Select
Selection.Delete Shift:=xlToLeft
Columns("H:H").Select
Selection.Delete Shift:=xlToLeft
Columns("I:W").Select
Selection.Delete Shift:=xlToLeft
Columns("J:J").Select
Selection.Delete Shift:=xlToLeft
Columns("K:L").Select
Selection.Delete Shift:=xlToLeft
Columns("L:L").Select
Selection.Delete Shift:=xlToLeft
Columns("M:AA").Select
Selection.Delete Shift:=xlToLeft
Columns("N:N").Select
Selection.Delete Shift:=xlToLeft
Columns("O:P").Select
Selection.Delete Shift:=xlToLeft
Columns("P:P").Select
Selection.Delete Shift:=xlToLeft
Columns("Q:AE").Select
Selection.Delete Shift:=xlToLeft
Columns("R:R").Select
Selection.Delete Shift:=xlToLeft
Columns("S:T").Select
Selection.Delete Shift:=xlToLeft
Columns("T:T").Select
Selection.Delete Shift:=xlToLeft
Columns("U:AG").Select
Selection.Delete Shift:=xlToLeft
Columns("V:V").Select
Selection.Delete Shift:=xlToLeft
Columns("W:X").Select
Selection.Delete Shift:=xlToLeft
Columns("X:X").Select
Selection.Delete Shift:=xlToLeft
Columns("Y:AM").Select
Selection.Delete Shift:=xlToLeft
Columns("Z:Z").Select
The reason this code looks so nasty is because when I was selecting multiple columns with something like "Columns("A:Z,AB:AC,AF:AF").Select, I was getting an overlap error.