ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Deleting cells in a row (https://www.excelbanter.com/excel-programming/327575-deleting-cells-row.html)

Jeff Wright[_2_]

Deleting cells in a row
 
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



William[_2_]

Deleting cells in a row
 
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




"Jeff Wright" wrote in message
news:93j8e.17010$lv1.10175@fed1read06...
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





Jeff Wright[_2_]

Deleting cells in a row
 
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


"William" wrote in message
...
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




"Jeff Wright" wrote in message
news:93j8e.17010$lv1.10175@fed1read06...
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







William[_2_]

Deleting cells in a row
 
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




"Jeff Wright" wrote in message
news:Jlk8e.17342$lv1.13098@fed1read06...
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


"William" wrote in message
...
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




"Jeff Wright" wrote in message
news:93j8e.17010$lv1.10175@fed1read06...
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









Jeff Wright[_2_]

Deleting cells in a row
 
Thanks, William! This works just fine.

Appreciatively,

Jeff

"William" wrote in message
...
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




"Jeff Wright" wrote in message
news:Jlk8e.17342$lv1.13098@fed1read06...
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


"William" wrote in message
...
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




"Jeff Wright" wrote in message
news:93j8e.17010$lv1.10175@fed1read06...
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












All times are GMT +1. The time now is 10:43 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com