请帮忙优化VBA代码

SubDC条件标记()Application.ScreenUpdating=False'关闭屏幕更新DimNAsLongN=Sheets("日程").Range("M7"... Sub DC条件标记()
Application.ScreenUpdating = False '关闭屏幕更新
Dim N As Long
N = Sheets("日程").Range("M7") * 200
For i = 1 To N Step 200
Range(Cells(i, 2), Cells(i + 199, 2)).AutoFilter
Selection.AutoFilter Field:=1, Criteria1:="10", Operator:=xlBottom10Items
Range(Cells(i + 1, 2), Cells(i + 199, 2)).Interior.ColorIndex = 17
Selection.AutoFilter
Next
For i = 1 To N Step 200
Range(Cells(i, 3), Cells(i + 199, 3)).AutoFilter
Selection.AutoFilter Field:=1, Criteria1:="10", Operator:=xlBottom10Items
Range(Cells(i + 1, 3), Cells(i + 199, 3)).Interior.ColorIndex = 17
Selection.AutoFilter
Next
For i = 1 To N Step 200
Range(Cells(i, 10), Cells(i + 199, 10)).AutoFilter
Selection.AutoFilter Field:=1, Criteria1:="10", Operator:=xlTop10Percent
Range(Cells(i + 1, 10), Cells(i + 199, 10)).Interior.ColorIndex = 17
Selection.AutoFilter
Next
For i = 1 To N Step 200
Range(Cells(i, 11), Cells(i + 199, 11)).AutoFilter
Selection.AutoFilter Field:=1, Criteria1:="10", Operator:=xlTop10Percent
Range(Cells(i + 1, 11), Cells(i + 199, 11)).Interior.ColorIndex = 17
Selection.AutoFilter
Next
For i = 1 To N Step 200
Range(Cells(i, 15), Cells(i + 199, 15)).AutoFilter
Selection.AutoFilter Field:=1, Criteria1:="10", Operator:=xlTop10Percent
Range(Cells(i + 1, 15), Cells(i + 199, 15)).Interior.ColorIndex = 17
Selection.AutoFilter
Next
For i = 1 To N Step 200
Range(Cells(i, 17), Cells(i + 199, 17)).AutoFilter
Selection.AutoFilter Field:=1, Criteria1:="10", Operator:=xlTop10Percent
Range(Cells(i + 1, 17), Cells(i + 199, 17)).Interior.ColorIndex = 17
Selection.AutoFilter
Next
For i = 1 To N Step 200
Range(Cells(i, 24), Cells(i + 199, 24)).AutoFilter
Selection.AutoFilter Field:=1, Criteria1:="10", Operator:=xlTop10Percent
Range(Cells(i + 1, 24), Cells(i + 199, 24)).Interior.ColorIndex = 17
Selection.AutoFilter
Next
Application.ScreenUpdating = True
End Sub
展开
 我来答
yueliang_914
2008-07-03 · TA获得超过1532个赞
知道大有可为答主
回答量:791
采纳率:0%
帮助的人:1186万
展开全部
Sub yueliang()
Dim N As Long
Dim i, l As Integer
Dim SearchString As String
SearchString = " 10, 11, 15, 17, 24"
N = Sheets("日程").Range("M7") * 200
Application.ScreenUpdating = False
For i = 1 To N Step 200
For l = 2 To 3
Range(Cells(i, l), Cells(i + 199, l)).AutoFilter
Selection.AutoFilter Field:=1, Criteria1:="10", Operator:=xlBottom10Items
Range(Cells(i + 1, l), Cells(i + 199, l)).Interior.ColorIndex = 17
Selection.AutoFilter
Next
Next

For i = 1 To N Step 200
For l = 10 To 24
If InStr(SearchString, Str(l)) > 0 Then
Range(Cells(i, l), Cells(i + 199, l)).AutoFilter
Selection.AutoFilter Field:=1, Criteria1:="10", Operator:=xlTop10Percent
Range(Cells(i + 1, l), Cells(i + 199, l)).Interior.ColorIndex = 17
Selection.AutoFilter
End If
Next
Next
Application.ScreenUpdating = True
End Sub
AiPPT
2024-09-19 广告
随着AI技术的飞速发展,如今市面上涌现了许多实用易操作的AI生成工具1、简介:AiPPT: 这款AI工具智能理解用户输入的主题,提供“AI智能生成”和“导入本地大纲”的选项,生成的PPT内容丰富多样,可自由编辑和添加元素,图表类型包括柱状图... 点击进入详情页
本回答由AiPPT提供
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式