EXCEL 用VB 筛选条件除某个值以外所有项都选中,要怎么写
你中轿这是数据透视表的操作吧?
ActiveSheet.Range("$A$1:$C$20").AutoFilter Field:=1, Criteria1:="反选的内容", Operator:=xlAnd
数据透视表的操作
ActiveSheet.PivotTables([你的表名]).PivotFields([你卖孝肆的字段名]).PivotFilters.Add Type:= _
xlCaptionDoesNotEqual, Value1:="你的反选内容"
ActiveSheet.Range("$A$1:$C$20").AutoFilter Field:=1, Criteria1:="反选的内容", Operator:=xlAnd
'或者
ActiveSheet.PivotTables([你的表名]).PivotFields([你的字段名]).PivotFilters.Add Type:= _
xlCaptionDoesNotEqual, Value1:="你慎猜的反选内容"
VB调用EXCEL筛选
自动缓卜筛选只能有两个条件,不过可以允许多个值筛选,采用下面的方法就可以了。
Worksheets("卜哪运Sheet1").Range("A1").AutoFilter_
Field:=7, _
Criteria1:=Array( "型梁a","b","c"), Operator:=xlFilterValues
如何用VB控制excel的筛选并删除筛选结果
EXCEL中使用高级筛选可以将筛选结果直接复制到其它区域,无须另外手动复制粘贴;
高级筛选可以使用通配符“*”筛笑敏选出含某些字符的记录;
列出筛选条件,选则告择:数据--排序和筛选--高级;
打开高级孙升明筛选对话框,选择区域和选项,这里选择“将筛选结果复制到其他位置”,即可将筛选结果复制出来,并且可以指定复制到的位置(如果是所有字段都复制出来,可以只选择左上角一个单元格,比如下图的复制到可以为$A$11)。
VB能不能实现excel中的筛选
可以实现的;
Private Type num
xuhao As Integer
隐雀 i As Integer
End Type
Dim a(10) As num
Dim temp As num
Private Sub Command1_Click()
For i = 1 To 10
a(i).i = InputBox("请输入第"凯携码 i "个数字")
a(i).xuhao = i
Print a(i).i
Next i
For i = 1 To 10
For j = 1 To 10 - i
If a(j).i a(j + 1).i Then
temp = a(j + 1)
a(j + 1) = a(j)
a(j) = temp
End If
Next j
Next i
Print "最大数盯哪字是" a(10).i " 位置是" a(10).xuhao
End Sub
VB调用excle时按要求筛选
On Error GoTo errline
CommonDialog1.Flags = cdlCFBoth
CommonDialog1.Filter = "excel文件(*.xls) | *.xls|excel文件(*.xlsx) | *.xlsx"
CommonDialog1.CancelError = True '保证在取消对话框不报错
CommonDialog1.ShowOpen
Dim xlApp As Excel.Application, xlBook As Excel.Workbook, xlSheet As Excel.Worksheet
Dim I As Long, J As Long,BomData() as string,Num as integer
Set xlApp = New Excel.Application
汪尺哪 xlApp.Visible = False
Set xlBook = xlApp.Workbooks.Open(Text1.Text)
Set xlSheet = xlBook.Sheets(1)
With xlSheet
RowBom = .Cells(.Rows.Count, 1).End(xlUp).Row - 1
ColBom = .Cells(1, .Columns.Count).End(xlToLeft).Column
ReDim BomData(RowBom, ColBom)
For I = 1 To RowBom
if BomData(I, 1) ="444" and bomdata(i,4)="困码123" then
num = num+1
endif
Next 困激I
End With
xlBook.Close
xlApp.Quit
Set xlSheet = Nothing
Set xlBook = Nothing
Set xlApp = Nothing
text1.text = num
errline:
If Err.Number 0 Then
MsgBox CStr(Err.Number) + "" + Err.Description, vbOKOnly + vbInformation
End If
Err.Clear
VB筛选excle中的数据
写一段excel导入到datagrid控件里的代码,然誉段后在窗体里新建一个TEXT得控件
用SQL的SELECT AVG(年并数龄) AS xxxx FROM XXXX表 把SELECT求出的平庆蔽誉均值赋给TEXT,然后就可以显示给你看了