Deleting cells in a row

  • Thread starter Thread starter Jeff Wright
  • Start date Start date
J

Jeff Wright

I want to write a subroutine which will delete specific cells in a row. For
example, if the active cell is A13, I want the macro to delete cells B13
through E13, and also cells H13 through M13.

Your help is appreciated.

Jeff
 
Hi Jeff

Assuming it is the cells in Columns B-E and Columns H-M of the currently
selected row that you want deleted, then try...

Sub Test()
With ThisWorkbook.Sheets("Sheet1")
Application.Intersect(ActiveCell.EntireRow, _
..Range("B:E,H:M")).Delete Shift:=xlUp
End With
End Sub

-----
XL2003
Regards

William

(e-mail address removed)
 
William, this works fine except the macro moves the data from the cells
below up into the just-cleared cells. I don't want this. I just want to
leave the cells empty.

Thanks,

Jeff
 
Hi Jeff

I thought you might say that! There is a difference between "delete" and
"clear". Try this...

Sub Test()
With ThisWorkbook.Sheets("Sheet1")
Application.Intersect(ActiveCell.EntireRow, _
..Range("B:E,H:M")).ClearContents
End With
End Sub

--

-----
XL2003
Regards

William

(e-mail address removed)
 
Back
Top