首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VBA >

怎么组织Excel的VBA命令,来实现Sql的where功能

2012-03-26 
如何组织Excel的VBA命令,来实现Sql的where功能。Excel的vba能否实现SQL的这项功能?select a1,a2,a3,a4,a5,a

如何组织Excel的VBA命令,来实现Sql的where功能。
Excel的vba能否实现SQL的这项功能?

select a1,a2,a3,a4,a5,a6 From [Tbale$] Where a1=数据1 and a2=数据2 and a3=数据3 and a4=数据4 

用AutoFilter功能只能有两个条件,
Find本身只有一个功能,是需要多个find命令组合而成,???




[解决办法]
看个例子:
Sub Macro1()
With ActiveSheet.QueryTables.Add(Connection:=Array( _
"OLEDB;Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\Book1.xls;Jet OLEDB:Engine Type=35"), Destination:=Range("C1"))
.CommandType = xlCmdSql
.CommandText = Array("select distinct A from [Sheet1$] where A in (select distinct B from [Sheet1$])")
.Refresh BackgroundQuery:=False
End With
End Sub

热点排行