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

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.

Damon Ostrander

MrExcel MVP
Joined
Feb 17, 2002
Messages
4,239
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
 

ironsides

Well-known Member
Joined
Aug 12, 2002
Messages
575
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.
 

Forum statistics

Threads
1,136,878
Messages
5,678,300
Members
419,753
Latest member
Sallylwy

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
Top