|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
- Set SH0 = Worksheets("查询")
- Set SH1 = Worksheets("税务")
- Set SH2 = Worksheets("交警")
- Set SH3 = Worksheets("工商")
- Str_coon = "HDR=yes';Data Source =" & ThisWorkbook.FullName '//OFFICE2003,2007 通用
- StrSQL = ""
- StrSQL = StrSQL & "SELECT 姓名,证件号码"
- StrSQL = StrSQL & ",MAX(所得税) AS 所得税"
- StrSQL = StrSQL & ",MAX(车辆号码) AS 车辆号码"
- StrSQL = StrSQL & ",MAX(企业名称) AS 企业名称"
- StrSQL = StrSQL & " FROM ("
- StrSQL = StrSQL & " SELECT 姓名,证件号码,0 AS 所得税,NULL AS 车辆号码,NULL AS 企业名称"
- StrSQL = StrSQL & " FROM [" & SH0.Name & "$]"
- StrSQL = StrSQL & " UNION ALL "
- StrSQL = StrSQL & " SELECT 姓名,证件号码,所得税,NULL AS 车辆号码,NULL AS 企业名称"
- StrSQL = StrSQL & " FROM [" & SH1.Name & "$]"
- StrSQL = StrSQL & " UNION ALL "
- StrSQL = StrSQL & " SELECT 姓名,证件号码,0 AS 所得税,车辆号码,NULL AS 企业名称"
- StrSQL = StrSQL & " FROM [" & SH2.Name & "$]"
- StrSQL = StrSQL & " UNION ALL "
- StrSQL = StrSQL & " SELECT 姓名,证件号码,0 AS 所得税,NULL AS 车辆号码,企业名称"
- StrSQL = StrSQL & " FROM [" & SH3.Name & "$]"
-
- StrSQL = StrSQL & ") WHERE NOT 姓名 IS NULL GROUP BY 姓名,证件号码"
复制代码 |
|