Private Sub CommandButton1_Click()
For i = 2 To Range("a65536").End(xlUp).Row
v = Range("e" & i)
For Each t In Array("A", "B", "C", "D", "E", "F")
If InStr(v, t) > 0 Then
Range("k" & i) = 333
End If
Next t
For Each b In Array("1G", "2G", "3G", "4G", "5G", "6G", "7G")
If InStr(v, b) > 0 Then
Range("k" & i) = 222
End If
Next b
Next i
End Sub
-----
怎么让它只在当前筛选坏境下进行操作,而不是对整个表格操作。应该在哪里插入“Rows(i).Hidden = False”代码
或者说其他方法,也可以是,如果B列=某某,那么执行该代码
excel vba 请问这段代码怎么让它只在当前筛选条件下执行
答案:2 悬赏:0 手机版
解决时间 2021-01-30 15:06
- 提问者网友:你独家记忆
- 2021-01-29 17:17
最佳答案
- 五星知识达人网友:动情书生
- 2021-01-29 18:09
Private Sub CommandButton1_Click()
For i = 2 To Range("a65536").End(xlUp).Row
if rows(i).hidden=false then
v = Range("e" & i)
For Each t In Array("A", "B", "C", "D", "E", "F")
If InStr(v, t) > 0 Then
Range("k" & i) = 333
End If
Next t
For Each b In Array("1G", "2G", "3G", "4G", "5G", "6G", "7G")
If InStr(v, b) > 0 Then
Range("k" & i) = 222
End If
Next b
end if
Next i
End Sub
For i = 2 To Range("a65536").End(xlUp).Row
if rows(i).hidden=false then
v = Range("e" & i)
For Each t In Array("A", "B", "C", "D", "E", "F")
If InStr(v, t) > 0 Then
Range("k" & i) = 333
End If
Next t
For Each b In Array("1G", "2G", "3G", "4G", "5G", "6G", "7G")
If InStr(v, b) > 0 Then
Range("k" & i) = 222
End If
Next b
end if
Next i
End Sub
全部回答
- 1楼网友:天凉才是好个秋
- 2021-01-29 19:43
没图表,那个宏程序要根据你所在列和写筛选语言的。
示例:
dim i, a, j, x as integer
dim w as string
sheets("rework").select
cells.clear
sheets("sun").select
x = inputbox("请输入你想查询的工号", "查询表格")
for i = 2 to 8
if cells(1, 1) = "" then
i = i + 1
end if
w = cells(i, 238).value
on error resume next
sheets(w).select
range("k1").select
selection.autofilter field:=11, criteria1:="=" & x, operator:=xland
range("a2:o8000").select
selection.copy
sheets("rework").select
a = range("a65536").end(xlup).row + 1
cells(a, 1).select
activesheet.paste
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯