Bewerken

Delen via


Worksheet.Rows property (Excel)

Returns a Range object that represents all the rows on the specified worksheet.

Syntax

expression.Rows

expression A variable that represents a Worksheet object.

Remarks

Using the Rows property without an object qualifier is equivalent to using ActiveSheet.Rows. If the active document isn't a worksheet, the Rows property fails.

To return a single row, use the Item property or equivalently include an index in parentheses. For example, both Rows(1) and Rows.Item(1) return the first row of the active sheet.

Example

This example deletes row three on Sheet1.

Worksheets("Sheet1").Rows(3).Delete

This example deletes all rows on worksheet one where the value of cell one in the row is the same as the value of cell one in the previous row.

For Each rw In Worksheets(1).Rows 
   this = rw.Cells(1, 1).Value 
   If this = last Then rw.Delete 
   last = this 
Next

Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.