Range.EntireRow 屬性 (Excel)
會傳回 Range 物件,代表包含指定範圍的整個資料列 (或) 列。 唯讀。
語法
運算式。EntireRow
expression 代表 Range 物件的變數。
範例
此範例將針對包含使用中儲存格的列,設定其中第一個儲存格的值。 此範例必須在工作表上執行。
ActiveCell.EntireRow.Cells(1, 1).Value = 5
此範例將排序工作表上的所有資料列,包括隱藏的列。
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
支援和意見反應
有關於 Office VBA 或這份文件的問題或意見反應嗎? 如需取得支援服務並提供意見反應的相關指導,請參閱 Office VBA 支援與意見反應。
意見反應
https://aka.ms/ContentUserFeedback。
即將登場:在 2024 年,我們將逐步淘汰 GitHub 問題作為內容的意見反應機制,並將它取代為新的意見反應系統。 如需詳細資訊,請參閱:提交並檢視相關的意見反應