ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   help on deleting several rows at once (https://www.excelbanter.com/excel-programming/318546-help-deleting-several-rows-once.html)

hsg

help on deleting several rows at once
 
I wish to delete multiple, non continuous rows at once. When such rows are
selected, it says "This operation can not be performed on multiple objects".
The rows in question run into hundreds, say I would like to delete all even
rows, or every third row from ROW 1 onwards

can you please help


Frank Kabel

help on deleting several rows at once
 
Hi
do you have merged cells in your selected range. Also you may post the code
you have tried

"hsg" wrote:

I wish to delete multiple, non continuous rows at once. When such rows are
selected, it says "This operation can not be performed on multiple objects".
The rows in question run into hundreds, say I would like to delete all even
rows, or every third row from ROW 1 onwards

can you please help


hsg

help on deleting several rows at once
 
Actually I want to delete, in present case, all even numbered rows, and there
are no merged cells, and I have not tried any code so far.

I selected alternate rows, and deleted by right clicking and "delete",

but since the rows number into hundreds or so, I wanted to know how can this
be done using a macro, or otherwise also.

harsh

"Frank Kabel" wrote:

Hi
do you have merged cells in your selected range. Also you may post the code
you have tried

"hsg" wrote:

I wish to delete multiple, non continuous rows at once. When such rows are
selected, it says "This operation can not be performed on multiple objects".
The rows in question run into hundreds, say I would like to delete all even
rows, or every third row from ROW 1 onwards

can you please help


Sharad

help on deleting several rows at once
 

Below code will delete Odd rows, in the used range:-

Sub delRowOdd()
Dim i As Long, rDelRow As Range, totRows As Long

With Worksheets("Sheet1")
totRows = .UsedRange.Cells.Rows.Count
Set rDelRow = .Rows(1)
For i = 1 To totRows Step 2
Set rDelRow = Union(rDelRow, .Rows(i))
Next i
End With
rDelRow.EntireRow.Delete

End Sub

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Dave Peterson[_5_]

help on deleting several rows at once
 
Manually:

Insert a new column (column A).

Put X in A1
Put Y in A2

Select A1:A2 and rightclick and drag down.
let go and choose copy.

Apply Data|filter|autofilter and show only the rows you want to delete.
select those visible rows and rightclick|delete|entirerow

Remove the autofilter and delete your helper column.



hsg wrote:

I wish to delete multiple, non continuous rows at once. When such rows are
selected, it says "This operation can not be performed on multiple objects".
The rows in question run into hundreds, say I would like to delete all even
rows, or every third row from ROW 1 onwards

can you please help


--

Dave Peterson


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

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