|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
现在用字典方法实Select From [Sheet3$] Where 功能,只能用循环方法。
- Sub DELDELDEL()
- Dim Str, Rs As ADODB.Recordset
- Str = "Select AAAA, BBBB From [Sheet3$A1:C876] Where AAAA = 'IMG_20231107_095633.jpg'"
-
- Debug.Print Str
-
- Set Rs = SqlRetuRs(Str)
- Debug.Print Rs.RecordCount
-
- End Sub
复制代码
- Function SqlRetuRs(Str)
- Dim Cn As ADODB.Connection
- Set Cn = New ADODB.Connection
- Dim Rs As ADODB.Recordset
- Set Rs = New ADODB.Recordset
- Cn.Open "Provider=Microsoft.ACE.OLEDB.12.0;Extended Properties='Excel 12.0;HDR=yes';data source=" & ThisWorkbook.FullName
- Rs.Open Str, Cn, adOpenKeyset, adLockOptimistic
- Set SqlRetuRs = Rs
- End Function
复制代码
|
|