|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
- Sub AAADO()
- Dim cnn As Object, rs As Object, SQL$, c As Range
- Set cnn = CreateObject("ADODB.Connection")
- cnn.Open "Provider = Microsoft.ace.Oledb.12.0;Extended Properties ='Excel 12.0;hdr=no';Data Source =" & ThisWorkbook.Path & "\BB.xlsm"
- For Each c In Range("C5,F12,F18:M19")
- If Len(c.Value) Then t = c.Value Else t = "null"
- SQL = "update [Sheet1$" & c.Address(0, 0) & ":c" & c.Address(0, 0) & "] set f1=" & t
- Set rs = cnn.Execute(SQL)
- Next
- cnn.Close
- Set rs = Nothing
- Set cnn = Nothing
- End Sub
复制代码 |
|