【发布时间】:2019-10-24 03:49:14
【问题描述】:
我需要一个代码来根据项目中某些特定单元格的不同值给出消息,我已经在 Excel 中使用过 VBA,但从未在 Project 中使用过,所以我不知道该怎么做
我在 VBA Excel 中编写了一个代码,该代码与我在 Project 中需要做的事情相同,但我需要该代码,但需要包含项目的信息,但我在 Excel 中使用的函数并未在 Project 中定义,所以我不知道如何添加代码
Option Explicit
Private Sub Avance()
Dim PtjR As Double
Dim PtjP As Double
Dim FechaRI As Date
Dim FechaRF As Date
Dim FechaPI As Date
Dim FechaPF As Date
Dim ListaT As String
Dim i As Integer
Dim ListaTT As String
For i = 3 To 40
FechaPI = Round(Cells(i, 2).Value, 2)
FechaPF = Cells(i, 3).Value
FechaRI = Cells(i, 4).Value
FechaRF = Cells(i, 5).Value
PtjR = Round(Cells(i, 6).Value, 2)
PtjP = Round(Cells(i, 7).Value, 2)
If PtjR < PtjP Then
ListaT = ListaT & vbNewLine & Chr(13) & "La tarea" & " " & Cells(i, 1).Value & " " & "se encuentra en DELATE, lleva" & " " & PtjR * 100 & "% y debería llevar" & " " & PtjP * 100 & "%"
If FechaPF - DateValue(Now) < 0 Then
ListaT = ListaT & ". Esta tarea debió terminar hace " & -(FechaPF - DateValue(Now)) & " días."
ElseIf FechaPF - DateValue(Now) <= 7 Then
ListaT = ListaT & ". Esta tarea termina en " & FechaPF - DateValue(Now) & " días."
End If
End If
Next i
MsgBox ListaT, vbCritical, "Advertencia"
End Sub
我不确定获取单元格值的方式是否是唯一会改变代码的方式,但知道如何做到这一点会有很大帮助
【问题讨论】:
标签: vba ms-project