|
- Set SH0 = Sheets("【14】2")
- Set SH1 = Sheets("查询")
- SH1.Range("A4:Z65536").ClearContents
-
- Str_coon = "HDR=yes';Data Source =" & ThisWorkbook.FullName '//OFFICE2003,2007 通用
-
- Rem 第一行可以自己增加标题
- Rem 标题下内容必须是:文本格式
- Rem 结果表标题和数据表标题顺序相同
- Rem MAXCOL 现在是:Z,可以自己加长,例如改为:AZ
-
- MAXCOL = "Z"
-
- StrSQL = "SELECT * FROM [" & SH0.Name & "$A5:" & MAXCOL & "] WHERE 1=1"
- If SH1.Range("A2").Value = "模糊" Then
- For ICOL = 2 To SH1.Range(MAXCOL & "1").End(xlToLeft).Column
- If SH1.Cells(1, ICOL).Value <> "" And SH1.Cells(2, ICOL).Value <> "" Then
- StrSQL = StrSQL & " AND " & SH1.Cells(1, ICOL).Value & " LIKE '%" & SH1.Cells(2, ICOL).Value & "%'"
- End If
- Next
- Else
- For ICOL = 2 To SH1.Range(MAXCOL & "1").End(xlToLeft).Column
- If SH1.Cells(1, ICOL).Value <> "" And SH1.Cells(2, ICOL).Value <> "" Then
- StrSQL = StrSQL & " AND " & SH1.Cells(1, ICOL).Value & "='" & SH1.Cells(2, ICOL).Value & "'"
- End If
- Next
-
- End If
复制代码 |
|