excel 中使用vba实现列的筛选
答案:4 悬赏:40 手机版
解决时间 2021-11-20 06:23
- 提问者网友:轻浮
- 2021-11-19 21:12
excel 中使用vba实现列的筛选
最佳答案
- 五星知识达人网友:渊鱼
- 2021-11-19 22:49
一般采用倒序的方式:例如,将D列中为“否”的整行删除:
Sub test()
For i = Cells(Rows.Count, 4).End(xltoup).Row To 1
If Range("D" & i) = "否" Then
Range("D" & i).EntireRow.Delete
End If
Next
End Sub
Sub test()
For i = Cells(Rows.Count, 4).End(xltoup).Row To 1
If Range("D" & i) = "否" Then
Range("D" & i).EntireRow.Delete
End If
Next
End Sub
全部回答
- 1楼网友:廢物販賣機
- 2021-11-20 01:10
Sub xianshiM()
Dim EndC As Integer, i As Integer
Columns.Hidden = False
EndC = Range("A1").End(xlToRight).Column
For i = 1 To EndC
If InStr(Cells(1, i), "M") > 0 Then
Columns(i).Hidden = False
Else
Columns(i).Hidden = True
End If
Next
End Sub
Sub xianshiN()
Dim EndC As Integer, i As Integer
Columns.Hidden = False
EndC = Range("A1").End(xlToRight).Column
For i = 1 To EndC
If InStr(Cells(1, i), "N") > 0 Then
Columns(i).Hidden = False
Else
Columns(i).Hidden = True
End If
Next
End Sub
Sub xianshquanbu()
Columns.Hidden = False
End Sub
Dim EndC As Integer, i As Integer
Columns.Hidden = False
EndC = Range("A1").End(xlToRight).Column
For i = 1 To EndC
If InStr(Cells(1, i), "M") > 0 Then
Columns(i).Hidden = False
Else
Columns(i).Hidden = True
End If
Next
End Sub
Sub xianshiN()
Dim EndC As Integer, i As Integer
Columns.Hidden = False
EndC = Range("A1").End(xlToRight).Column
For i = 1 To EndC
If InStr(Cells(1, i), "N") > 0 Then
Columns(i).Hidden = False
Else
Columns(i).Hidden = True
End If
Next
End Sub
Sub xianshquanbu()
Columns.Hidden = False
End Sub
- 2楼网友:忘川信使
- 2021-11-20 00:35
录制三个宏就行了。
- 3楼网友:污到你湿
- 2021-11-19 23:50
下面是3个宏的代码,分别绑定到3个按钮上
Sub combutton1()
Dim a As Range
Range("A1:iv1").EntireColumn.Hidden = False
For Each a In Range("A1:iv1")
If a = "M" Or a = "m" Then a.EntireColumn.Hidden = True
Next
End Sub
Sub combutton2()
Dim a As Range
Range("A1:iv1").EntireColumn.Hidden = False
For Each a In Range("A1:iv1")
If a = "N" Or a = "n" Then a.EntireColumn.Hidden = True
Next
End Sub
Sub combtton3()
Dim a As Range
endcol = Range("iv1").End(xlToLeft).Column
Range("A1:iv1").EntireColumn.Hidden = False
End Sub追问谢谢!还有点小问题
endcol = Range("iv1").End(xlToLeft).Column
这句是干什么的啊
Sub combutton1()
Dim a As Range
Range("A1:iv1").EntireColumn.Hidden = False
For Each a In Range("A1:iv1")
If a = "M" Or a = "m" Then a.EntireColumn.Hidden = True
Next
End Sub
Sub combutton2()
Dim a As Range
Range("A1:iv1").EntireColumn.Hidden = False
For Each a In Range("A1:iv1")
If a = "N" Or a = "n" Then a.EntireColumn.Hidden = True
Next
End Sub
Sub combtton3()
Dim a As Range
endcol = Range("iv1").End(xlToLeft).Column
Range("A1:iv1").EntireColumn.Hidden = False
End Sub追问谢谢!还有点小问题
endcol = Range("iv1").End(xlToLeft).Column
这句是干什么的啊
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯