private sub insert1_click()
dim icount as integer
dim cn
set cn = createobject("adodb.connection")
cn.connectionstring = "provider=sqloledb.1;persist security info=false;user id=sa;password=8233;initial catalog=hskmis;data source=127.0.0.1"
cn.open
cn.execute ("delete temp9")
'計算該錶有多少行
rowcount = worksheets("fc").usedrange.rows.count
'行迴圈
for irow = 1 to rowcount
strrecord = ""
'列迴圈,假設有五列,從第一列開始
for icol = 1 to 5
if icol <> 5 then
strrecord = strrecord & "'" & worksheets("fc").cells(irow, icol).value & "'" & ","
else
strrecord = strrecord & "'" & worksheets("fc").cells(irow, icol).value & "'"
end if
next
msgbox strrecord
sql = cn.execute("insert into temp9 values(" & strrecord & ")")
next
msgbox "插入完成"
end sub
VBA將Excel匯出為CSV檔案
sub csv dim fs,myfile as object dim myfileline as string txtfile的行資料 dim sht as worksheet dim csvfilename as string csv檔名 dim totalrows as integer 總的行...
Excel中使用VBA訪問Access資料庫
excel中使用vba的優點 巨集是vba的一種簡單應用。巨集可以通過編寫vba 錄製巨集兩種方式獲得。通常是先錄製巨集,再在獲得的巨集的基礎上進行語句優化調整,最後得到想要的巨集。在 誰說菜鳥不會資料分析 工具篇 第四章 讓報告自動化中,涉及到根據輸入日期,從access資料庫中提取相關資料到ex...
excel日期轉換為週數 VBA將日期轉換為週數
6 個答案 答案 0 得分 12 要將週數作為第一天的星期一,請使用以下內容 worksheetfunction.weeknum now,vbmonday 答案 1 得分 6 使用vba將日期轉換為isoweeknumber,您只需要datepart函式 其中dt是感興趣的日期 isoweeknum...