|
- Sub Opiona()
- 'On Error Resume Next '// 发生错误,自动执行下一句,就是忽略错误
- Application.ScreenUpdating = False '//关闭屏幕刷新
- Application.DisplayAlerts = False '//关闭系统提示
- t = Timer '//开始时间
- Set SH0 = Sheets("【14】2")
- Set SH1 = Sheets("查询")
- SH1.Range("A4:Z65536").ClearContents
-
- Str_coon = "HDR=yes';Data Source =" & ThisWorkbook.FullName '//OFFICE2003,2007 通用
- StrSQL = "SELECT * FROM [" & SH0.Name & "$A5:Z] WHERE 1=1"
- If SH1.Range("C2").Value = "模糊" Then
- If SH1.Range("A2").Value <> "" Then StrSQL = StrSQL & " AND " & SH1.Range("A1").Value & " LIKE '%" & SH1.Range("A2").Value & "%'"
- If SH1.Range("B2").Value <> "" Then StrSQL = StrSQL & " AND " & SH1.Range("B1").Value & " LIKE '%" & SH1.Range("B2").Value & "%'"
- Else
- If SH1.Range("A2").Value <> "" Then StrSQL = StrSQL & " AND " & SH1.Range("A1").Value & "='" & SH1.Range("A2").Value & "'"
- If SH1.Range("B2").Value <> "" Then StrSQL = StrSQL & " AND " & SH1.Range("B1").Value & "='" & SH1.Range("B2").Value & "'"
- End If
- MsgBox StrSQL
- SQLARR = GET_SQL_To_Arr(StrSQL, Str_coon, False)
- SH1.Range("A4").Resize(UBound(SQLARR, 1) + 1, UBound(SQLARR, 2) + 1) = SQLARR
- Application.ScreenUpdating = True '//恢复屏幕刷新
- Application.DisplayAlerts = True '//恢复系统提示
- MsgBox "一共用时:" & Format(Timer - t, "#0.0000") & " 秒", , "北极狐提示!!" '//提示所用时间
- End Sub
复制代码 |
评分
-
1
查看全部评分
-
|