help on deleting several rows at once

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
Hi
do you have merged cells in your selected range. Also you may post the code
you have tried
 
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
 
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
 
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top