如果另一列具有“不”,我该如何复制特定列的值在里面?

发布于 2025-01-22 22:01:14 字数 580 浏览 1 评论 0原文

非常具体的问题。我有一个学习VBA的任务,但我真的找不到任何问题。

project中的外观

基本上是“ 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

萌面超妹 2025-01-29 22:01:14

显示的值(始终是字符串)和存储的值(日期,字符串,数字等)之间存在差异。在VBA中,使用存储值更简单。在这种情况下,sammelvorgang是一个布尔值的摘要(我相信),因此可以按这样的代码编写代码:

Sub schedule_Number()

Dim tsk As Task
For Each tsk In ActiveProject.Tasks
    
    If Not (tsk Is Nothing) Then
        If Not tsk.Summary Then
            tsk.Text7 = tsk.ID
        End If
    End If
    
Next tsk

不幸的是,在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:

Sub schedule_Number()

Dim tsk As Task
For Each tsk In ActiveProject.Tasks
    
    If Not (tsk Is Nothing) Then
        If Not tsk.Summary Then
            tsk.Text7 = tsk.ID
        End If
    End If
    
Next tsk

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文