Range.EntireRow property (Excel)
Returns a Range object that represents the entire row (or rows) that contains the specified range. Read-only.
Syntax
expression.EntireRow
expression A variable that represents a Range object.
Example
This example sets the value of the first cell in the row that contains the active cell. The example must be run from a worksheet.
ActiveCell.EntireRow.Cells(1, 1).Value = 5
This example sorts all the rows on a worksheet, including hidden rows.
Sub SortAll()
'Turn off screen updating, and define your variables.
Application.ScreenUpdating = False
Dim lngLastRow As Long, lngRow As Long
Dim rngHidden As Range
'Determine the number of rows in your sheet, and add the header row to the hidden range variable.
lngLastRow = Cells(Rows.Count, 1).End(xlUp).Row
Set rngHidden = Rows(1)
'For each row in the list, if the row is hidden add that row to the hidden range variable.
For lngRow = 1 To lngLastRow
If Rows(lngRow).Hidden = True Then
Set rngHidden = Union(rngHidden, Rows(lngRow))
End If
Next lngRow
'Unhide everything in the hidden range variable.
rngHidden.EntireRow.Hidden = False
'Perform the sort on all the data.
Range("A1").CurrentRegion.Sort _
key1:=Range("A2"), _
order1:=xlAscending, _
header:=xlYes
'Re-hide the rows that were originally hidden, but unhide the header.
rngHidden.EntireRow.Hidden = True
Rows(1).Hidden = False
'Turn screen updating back on.
Set rngHidden = Nothing
Application.ScreenUpdating = True
End Sub
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.
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기