VBA range.rows

The Rows property
represents all the rows on the specified worksheet or range.

We are going to use the following example.

Each cell inside the range B2 to C7 has values.

Let’s run the following code.

Delete all rows

Sub DeleteAllRows()
Range("B2:C7").Rows.Delete
End Sub

It will leave us with a blank worksheet.

That happens because we are deleting all rows in the
selected range. In this example, we would have the same effect if we used Range(“B2:C7”).Columns.Delete.

Delete the selected row

In order to delete a single row, we have to use the row number. Let’s delete the second row inside the selected range.

Sub DeleteAllRows()
Range("B2:C7").Rows(2).Delete
End Sub

If we run the above code, we are going to get the following
result.

The second row is removed from the selected range.

Delete a range of rows

You can specify a range inside a range. For example, let’s select the range B2:C7, and inside this range we are going to select rows 2, 3, and 4 and delete them. We could do this using the following lines of code: