Application.SelectCellDown 方法 (Project)

从当前选定范围向下选择单元格。

语法

expression. SelectCellDown( _NumCells_, _Extend_ )

expression:表示 Application 对象的变量。

参数

名称 必需/可选 数据类型 说明
NumCells 可选 Long 从当前选定范围向下选择的单元格数目。 默认值为 1。
Extend 可选 Boolean 如此 如果当前所选内容扩展到指定的单元格。 默认值为 False

返回值

Boolean

说明

当日历、 网络图或资源图表活动视图中, SelectCellDown 方法不可用。

示例

下面的示例将完成和未完成的资源组合应用到资源工作表视图中,然后使用 SelectCellDown 在每一行中选择第一个单元格并测试是否该行是分组内的任务。 直到行是空的然后显示消息框中各行的测试结果与继续该过程。

Sub ShowGroupByItems() 
 Dim isValid As Boolean 
 Dim res As Resource 
 Dim rowType As String 
 Dim msg As String 
 
 isValid = True 
 msg = "" 
 
 ActiveProject.Views("Resource Sheet").Apply 
 GroupApply Name:="Complete and Incomplete Resources" 
 Application.SelectBeginning 
 
 ' When a cell in an empty row is selected, accessing the ActiveCell.Resource 
 ' property results in error 1004. 
 On Error Resume Next 
 
 ' Loop until a cell in an empty row is selected. 
 While isValid 
 Set res = ActiveCell.Resource 
 
 If Err.Number > 0 Then 
 isValid = False 
 Debug.Print Err.Number 
 Err.Number = 0 
 Else 
 If res.GroupBySummary Then 
 rowType = "' is a group-by summary row." 
 Else 
 rowType = "' is a resource row." 
 End If 
 
 msg = msg & "Resource name: '" & res.Name & rowType & vbCrLf 
 SelectCellDown 
 End If 
 Wend 
 
 MsgBox msg, vbInformation, "GroupBy Summary for Resources" 
 
End Sub

支持和反馈

有关于 Office VBA 或本文档的疑问或反馈? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。