-2

我有一个 Excel 表,其中的数据像“输入表”一样呈现。如果每行中都存在 T1 或 T2,我需要使用 VBscript 进行搜索。如果找到了,那么“Task 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

谢谢

4

1 回答 1

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

谢谢

于 2012-12-11T11:13:16.927 回答