another VBA question

southpaw163

New Member
Joined
Aug 28, 2006
Messages
4
I have macro set up to delete selected row right now being:
Sub deleteactiverow()
Application.ScreenUpdating = False
ActiveSheet.Unprotect
ActiveCell.EntireRow.delete
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
End Sub

But I don't want it to delete the entire row, I only want it to delete columns A-M. Is there a way I can do this? I want it to somehow select columns A-M on the current row and just delete them. But since the number of the current row could change I don't know what code to put in there. Can anyone help me out here? So far everyone has answered all of my questions with ease so I'm hoping that keeps up!
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.

HalfAce

MrExcel MVP
Joined
Apr 6, 2003
Messages
9,454
Hello southpaw163. (welcome to the board.)
Do you mean something like this?
Code:
Sub deleteactiverow()
ActiveSheet.Unprotect
Range(Cells(ActiveCell.Row, "A"), _
      Cells(ActiveCell.Row, "M")).Delete
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
End Sub
Or do you not want these cells to shift up when deleted?
(If you don't then just replace 'Delete' with 'ClearContents'.)
 

Forum statistics

Threads
1,136,268
Messages
5,674,732
Members
419,523
Latest member
Urnovio

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