Macro problem

ironsides

Well-known Member
Joined
Aug 12, 2002
Messages
575
Excel2000. My work sheet is unlocked.

I'm using this macro successfully

Sub Delete()
'
' Delete Macro
' Macro recorded 10/11/2006 by USER
'
' Keyboard Shortcut: Ctrl+Shift+D

'
Range("C:C,E:E,F:F,G:G,M:M,O:O,Q:Q,S:S,T:T,U:U,V:V,W:W,X:X,Y:Y,AA:AA,AG:AG,AH:AH,AI:AI,AJ:AJ,AK:AK,AL:AL,AM:AM,AN:AN,AO:AO,AQ:AQ,AR:AR,AS:AS,AT:AT").Select
Range("AT1").Activate
Selection.Delete Shift:=xlToLeft

End Sub

I inserted five columns contiguously between AN:AN,AO:AO and edited the macro accordingly.

The edited macro does not work

Is it possible to insert cols and get the macro to work successfully?
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Hi ironsides,

The modified macro should work. I'm suspecting you accidentally introduced a syntax error (missing comma or similiar). When you say the edited macro "does not work," what do you mean? Does it delete the wrong columns? Do you get a run-time error? If so, what is the error message?

I should also point out that the 3 lines of code you posted could more efficiently be replaced by:

Range("C:C,E:G,M:M,O:O,Q:Q,S:Y,AA:AA,AG:AO,AQ:AT").Delete

Damon
 
Upvote 0
Range("C:C,E:E,F:F,G:G,M:M,O:O,Q:Q,S:S,T:T,U:U,V:V,W:W,X:X,Y:Y,AA:AA,AG:AG,AH:AH,AI:AI,AJ:AJ,AK:AK,AL:AL,AM:AM,AN:AN,
AO:AO,AQ:AQ,AR:AR,AS:AS,AT:AT,AY:AY").Select

Range("AT1").Activate
Selection.Delete Shift:=xlToLeft[/b]


Thank you all for looking and especially Damon for commenting. You opened my eyes.

I see my error.

I neglected to change my range to the last col which is AY not AT.
 
Upvote 0

Forum statistics

Threads
1,214,998
Messages
6,122,638
Members
449,093
Latest member
Ahmad123098

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