我有一张Excel工作表,其中的数据显示为“输入表”。如果每行中存在T1或T2,我需要使用VBscript进行搜索。如果找到,那么“任务compdate”列应该从下一个任务的直接“Stardate”列复制值(如果有的话)。
输入表:
Activity Task1 Task1 Stardate Task1 Compdate Task2 Task2 Stardate Task2 Compdate Task3 Task3 Stardate Task3 Compdate
A1 T1 02/01/2012 T1 04/01/2011 T3 09/02/2011
A2 T2 02/01/2012 T2 04/01/2011 T3 09/02/2011
A3 T1 02/01/2012 T4 04/01/2011 T3 09/02/2011
输出表:
Activity Task1 Task1 Stardate Task1 Compdate Task2 Task2 Stardate Task2 Compdate Task3 Task3 Stardate Task3 Compdate
A1 T1 02/01/2012 04/01/2011 T1 04/01/2011 09/02/2011 T3 09/02/2011
A2 T2 02/01/2012 04/01/2011 T2 04/01/2011 09/02/2011 T3 09/02/2011
A3 T1 02/01/2012 04/01/2011 T4 04/01/2011 T3 09/02/2011
更新代码:
IntRow6=2
Do While objSheet6.Cells(IntRow6,1).Value <> ""
DataCount=0
For DataCount=0 to UBound(VMHArray)
Set rSearch = objSheet6.Cells(IntRow6,1).EntireRow
Set rFound = rSearch.Find(VMHArray(DataCount))
If Not rFound Is Nothing Then
adrFirst = rFound.Address
Do
objSheet6.Cells(IntRow6,rFound.Column + 2)= objSheet6.Cells(IntRow6,rFound.Column + 5)
Set rFound = rSearch.FindNext(rFound)
Loop Until rFound.Address = adrFirst
End If
Next
IntRow6=IntRow6+1
Loop
由于
答案 0 :(得分:0)
更新代码:
IntRow6=2
Do While objSheet6.Cells(IntRow6,1).Value <> ""
DataCount=0
For DataCount=0 to UBound(VMHArray)
Set rSearch = objSheet6.Cells(IntRow6,1).EntireRow
Set rFound = rSearch.Find(VMHArray(DataCount))
If Not rFound Is Nothing Then
adrFirst = rFound.Address
Do
objSheet6.Cells(IntRow6,rFound.Column + 2)= objSheet6.Cells(IntRow6,rFound.Column + 5)
Set rFound = rSearch.FindNext(rFound)
Loop Until rFound.Address = adrFirst
End If
Next
IntRow6=IntRow6+1
Loop
由于