请按照收集了一些任务详细信息的表格。现在我正在这些类型的 excel 表上寻找可以检查所有 TCompdate 列的任何 VBscript,如果发现该列中没有值,则其相关的两列说这里 T,TSdate 应该是空白的。
输入表
PID T1 T1Sdate T1Compdate T2 T2Sdate T2Compdate T3 T3Sdate T3Compdate
10 A 2/5/11 4/5/11 B 06/09/12 C 11/11/11
11 A 2/5/11 B 06/09/12 8/8/10 C 11/11/11 5/4/11
12 A 2/5/11 B 06/09/12 8/8/10 C 11/11/11 5/4/11
输出表
PID T1 T1Sdate T1Compdate T2 T2Sdate T2Compdate T3 T3Sdate T3Compdate
10 A 2/5/11 4/5/11
11 B 06/09/12 8/8/10 C 11/11/11 5/4/11
12 B 06/09/12 8/8/10 C 11/11/11 5/4/11
代码:
Option Explicit
Dim objExcel1,objWorkbook
Dim strPathExcel1
Dim objSheet1,IntRow1
Dim Counter
Set objExcel1 = CreateObject("Excel.Application")
strPathExcel1 = "D:\VA\TestVBSScripts\DataNullification\DataNullification.xlsx"
Set objWorkbook=objExcel1.Workbooks.open(strPathExcel1)
Set objSheet1 = objExcel1.ActiveWorkbook.Worksheets(1)
IntRow1=2
Do While objSheet1.Cells(IntRow1,1).Value <> ""
For Counter=2 to 13 Step 3
If objSheet1.Cells(IntRow1,Counter+2).Value = "" Then
objSheet1.Cells(IntRow1,Counter).Value=""
objSheet1.Cells(IntRow1,Counter+1).Value=""
End If
Next
IntRow1=IntRow1+1
Loop
'=======================
objExcel1.ActiveWorkbook.SaveAs strPathExcel1
objExcel1.Workbooks.close
objExcel1.Application.Quit
'======================
谢谢,