如果另一列具有“不”,我该如何复制特定列的值在里面?
非常具体的问题。我有一个学习VBA的任务,但我真的找不到任何问题。
基本上是“ sammelvorgang”列,请说“ nein”,列“ Text7”应包含“ NR”的值。该行
浏览了VBA的基础知识,但我找不到针对特定列或特定行的解决方案。
Sub schedule_Number()
Dim tsk As Task
For Each tsk In ActiveProject.Tasks
If Not (tsk Is Nothing) Then
If (tsk.Sammelvorgang.Value = "Nein") Then
tsk.Text7 = tsk.Nr
End If
End If
Next tsk
End Sub
感谢您的帮助
Very specific question. I got a task to learn vba, but i cant really find anything for my problem.
screenshot of how it looks in project
Basically if the column "Sammelvorgang" says "Nein", the Column "Text7" should contain the Value of "Nr." of that row
Im looking through the basics of VBA but i cant find a solution to target a specific column or a specific row.
Sub schedule_Number()
Dim tsk As Task
For Each tsk In ActiveProject.Tasks
If Not (tsk Is Nothing) Then
If (tsk.Sammelvorgang.Value = "Nein") Then
tsk.Text7 = tsk.Nr
End If
End If
Next tsk
End Sub
Thanks for the help
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
显示的值(始终是字符串)和存储的值(日期,字符串,数字等)之间存在差异。在VBA中,使用存储值更简单。在这种情况下,sammelvorgang是一个布尔值的摘要(我相信),因此可以按这样的代码编写代码:
不幸的是,在vba中,对象名称,属性,方法全部使用英语。可能可以使用应用对象的方法从本地语言字段名称派生字段ID。 (但是,我没有任何非英语版本可以对此进行测试)。
然后使用字段ID, getfield 方法可用于返回 display value(string)。
这是英语语言文档:和 getfield 。
There is a difference between the displayed value (always a string) and the stored value (date, string, number, etc). In VBA it is simpler to use the stored value. In this case Sammelvorgang is Summary (I believe) which is a boolean, so the code can be written as such:
Unfortunately, in VBA the object names, properties, methods are all in English. It might be possible to use the FieldNameToFieldConstant method of the Application object to derive the field ID from the native language field names. (I don't have any non-English versions to test this, however).
Then with the Field ID, the GetField method can be used to return the display value (string).
Here is the English-language documentation: FieldNameToFieldConstant and GetField.