请帮忙优化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 展开
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 展开
展开全部
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
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 广告
2024-09-19 广告
随着AI技术的飞速发展,如今市面上涌现了许多实用易操作的AI生成工具1、简介:AiPPT: 这款AI工具智能理解用户输入的主题,提供“AI智能生成”和“导入本地大纲”的选项,生成的PPT内容丰富多样,可自由编辑和添加元素,图表类型包括柱状图...
点击进入详情页
本回答由AiPPT提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询