我的工作MS Excel的2010.I更新有一個Excel表如下圖所示:Excel的空日期欄,需要通過ADODB和VBScript
Process# requirementrcvd designdate codingdate test1 date test2 date deliverdate
11 10/11/2009 12/12/2009 02/02/2011 02/03/2011 09/03/2011 10/04/2011
12 10/11/2010 12/12/2011 15/02/2012
13 10/11/2009 12/12/2009 02/02/2011 02/03/2011
,所有的日期都在增加value.But給出我試圖獲得一些ADODB
功能,通過這些功能,我可以將日期值設置爲空,使其大於該記錄的最後一列日期。
說,作爲一個實例#12測試1日期,測試2日期,交貨日期是NULL
,所以通過.vbs腳本它應該設置爲16/02/2012,17/02/2012,18/02/2012
。
CODE:
顯式的選項
Dim conn, cmd, rs
Dim clauses(34), i
Dim xlApp, xlBook
Dim tempDate,LenDate
Set conn = CreateObject("ADODB.Connection")
With conn
.Provider = "Microsoft.ACE.OLEDB.12.0"
.ConnectionString = "Data Source=""D:\AravoVB\Final Scripts\GE_Wing_To_Wing_Report - Copy.xlsx"";" & _
"Extended Properties=""Excel 12.0;HDR=Yes"""
.Open
End With
'tempDate=""
For i = 0 To 34
clauses(i) = "IIf(IsNull([Task" & i + 1 & " Start Date]),Date()+"& i &",[Task" & i + 1 & " Start Date]) < IIf(IsNull([Task" & i + 2 & " Start Date]),Date()+"& i &",[Task" & i + 2 & " Start Date])"
tempDate=tempDate & "NVL([Task" & i + 1 & " Start Date],Date()+"& i &"),"
Next
'LenDate=Len(tempDate)-1
'tempDate=Mid(tempDate,1,LenDate)
MsgBox(tempDate)
Set cmd = CreateObject("ADODB.Command")
cmd.CommandText = "SELECT * FROM [GEWingToWingMay25$] WHERE [Business Process ID] NOT IN (" & "SELECT [Business Process ID] FROM [GEWingToWingMay25$] WHERE " & Join(clauses, " OR ") & ")"
MsgBox(cmd.CommandText)
cmd.ActiveConnection = conn
Set rs = cmd.Execute
Set xlApp = CreateObject("Excel.Application")
xlApp.Visible = True
Set xlBook = xlApp.Workbooks.Add
xlBook.Sheets(1).Range("A1").CopyFromRecordset cmd.Execute
'xlBook.Sheets(1).Cells(1,25).Value=cmd.CommandText
@Tukai爲什麼不寫一個'子'在圖表級別根據以前的日期值更新範圍內的所有空日期? – bonCodigo
@bonCodigo因爲我需要再做一遍循環技術,它將搜索2000行和160列,做這樣的比較。 –
我認爲您應該顯示您擁有的代碼,而不僅僅是電子表格內容。 – Tomalak