|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
- Sub demo()
- Dim serachVal$
-
- serachVal = Application.InputBox(Prompt:=" 请输入你要割接的IP地址?", Title:="提示", Default:="XX.XX.XX.XX", Left:=2, Top:=0, Type:=2)
- Dim conn As Object, rs As Object
-
- Set conn = CreateObject("adodb.connection")
-
- Set rs = CreateObject("adodb.recordset")
-
- conn.Open "Provider=Microsoft.ACE.OLEDB.12.0;Extended Properties='excel 12.0;HDR=NO;imex=2';Data Source=" & ThisWorkbook.FullName
- rs.Open "SELECT F4,F11 from [test1$] where F4 like '%" & serachVal & "%'", conn
-
- With Worksheets.Add
- .Name = "影响用户清单" & Format(Now, "yymmddhhmmss")
- .Range("a1").CopyFromRecordset rs
- End With
-
- Set rs = Nothing
-
- Set conn = Nothing
- End Sub
复制代码 直接用这个吧
|
|