码迷,mamicode.com
首页 > 编程语言 > 详细

vba--数组,多个表中的程序合并到一起,设置为一个按钮

时间:2019-07-21 00:56:30      阅读:171      评论:0      收藏:0      [点我收藏+]

标签:清空   option   北大   err   head   with   scaletype   format   clear   

Sub ttt()
t = Timer
Application.DisplayAlerts = False
清空数据
Sheets("买卖4").Select
Range("B2:K15").Select
Selection.ClearContents
Sheets("买卖M").Select
Range("B2:K15").Select
Selection.ClearContents
Sheets("买卖M转录").Select
Range("B2:K15").Select
Selection.ClearContents
Sheets("买卖总").Select
Range("B2:K15").Select
Selection.ClearContents
Sheets("新4").Select
Range("B2:K15").Select
Selection.ClearContents
Sheets("新M").Select
Range("B2:K15").Select
Selection.ClearContents
‘切换工作表运行程序
Sheets("买卖4").Select 

Range(
"A1:A12").Select ActiveWorkbook.ActiveSheet.Sort.SortFields.Clear ActiveWorkbook.ActiveSheet.Sort.SortFields.Add2 Key:=Range("A2:A12"), _ SortOn:=xlSortOnValues, Order:=xlAscending, CustomOrder:= _ "东一大区,东二大区,东三区,南一大区,南二大区,南三区,南四区,南五区,西一大区,西二大区,北一大区,北二大区,直销东南区", DataOption:= _ xlSortNormal With ActiveWorkbook.ActiveSheet.Sort .SetRange Range("A1:A12") .Header = xlYes .Apply End With Sheets("买卖M").Select Range("A1:A12").Select ActiveWorkbook.ActiveSheet.Sort.SortFields.Clear ActiveWorkbook.ActiveSheet.Sort.SortFields.Add2 Key:=Range("A2:A12"), _ SortOn:=xlSortOnValues, Order:=xlAscending, CustomOrder:= _ "东一大区,东二大区,东三区,南一大区,南二大区,南三区,南四区,南五区,西一大区,西二大区,北一大区,北二大区,直销东南区", DataOption:= _ xlSortNormal With ActiveWorkbook.ActiveSheet.Sort .SetRange Range("A1:A12") .Header = xlYes .Apply End With Sheets("买卖M转录").Select Range("A1:A12").Select ActiveWorkbook.ActiveSheet.Sort.SortFields.Clear ActiveWorkbook.ActiveSheet.Sort.SortFields.Add2 Key:=Range("A2:A12"), _ SortOn:=xlSortOnValues, Order:=xlAscending, CustomOrder:= _ "东一大区,东二大区,东三区,南一大区,南二大区,南三区,南四区,南五区,西一大区,西二大区,北一大区,北二大区,直销东南区", DataOption:= _ xlSortNormal With ActiveWorkbook.ActiveSheet.Sort .SetRange Range("A1:A12") .Header = xlYes .Apply End With Sheets("买卖总").Select Range("A1:A12").Select ActiveWorkbook.ActiveSheet.Sort.SortFields.Clear ActiveWorkbook.ActiveSheet.Sort.SortFields.Add2 Key:=Range("A2:A12"), _ SortOn:=xlSortOnValues, Order:=xlAscending, CustomOrder:= _ "东一大区,东二大区,东三区,南一大区,南二大区,南三区,南四区,南五区,西一大区,西二大区,北一大区,北二大区,直销东南区", DataOption:= _ xlSortNormal With ActiveWorkbook.ActiveSheet.Sort .SetRange Range("A1:A12") .Header = xlYes .Apply End With Sheets("新4").Select Range("A1:A12").Select ActiveWorkbook.ActiveSheet.Sort.SortFields.Clear ActiveWorkbook.ActiveSheet.Sort.SortFields.Add2 Key:=Range("A2:A12"), _ SortOn:=xlSortOnValues, Order:=xlAscending, CustomOrder:= _ "东一大区,东二大区,东三区,南一大区,南二大区,南三区,南四区,南五区,西一大区,西二大区,北一大区,北二大区,直销东南区", DataOption:= _ xlSortNormal With ActiveWorkbook.ActiveSheet.Sort .SetRange Range("A1:A12") .Header = xlYes .Apply End With Sheets("新M").Select Range("A1:A12").Select ActiveWorkbook.ActiveSheet.Sort.SortFields.Clear ActiveWorkbook.ActiveSheet.Sort.SortFields.Add2 Key:=Range("A2:A12"), _ SortOn:=xlSortOnValues, Order:=xlAscending, CustomOrder:= _ "东一大区,东二大区,东三区,南一大区,南二大区,南三区,南四区,南五区,西一大区,西二大区,北一大区,北二大区,直销东南区", DataOption:= _ xlSortNormal With ActiveWorkbook.ActiveSheet.Sort .SetRange Range("A1:A12") .Header = xlYes .Apply End With 添加数据 Dim a1, b1, c1, d1, e1, f1, a2, b2, c2, d2, e2, f2 As Integer Sheets("买卖4").Select 买卖4 arr1 = Sheets("买卖4质").Range("A1:D14") arr2 = Sheets("买卖4转").Range("A1:I14") For i = 2 To 12 For j = 2 To 14 买卖4质 If Cells(i, 1) = arr1(j, 1) Then 400接通量_买卖 Cells(i, 2) = arr1(j, 2) * arr1(j, 4) 400接听量_买卖 Cells(i, 3) = arr1(j, 2) * arr1(j, 4) * arr1(j, 3) 400接听率_买卖 On Error Resume Next Cells(i, 4) = Cells(i, 3) / Cells(i, 2) End If 买卖4转 If Cells(i, 1) = arr2(j, 1) Then 400商机量_买卖 Cells(i, 5) = arr2(j, 2) 400转录入量 Cells(i, 6) = arr2(j, 7) 400转录入率 Cells(i, 7) = arr2(j, 3) 400转带看量 Cells(i, 8) = arr2(j, 8) 400转带看率 Cells(i, 9) = arr2(j, 4) 400转成交量 Cells(i, 10) = arr2(j, 9) 400转成交率 Cells(i, 11) = arr2(j, 5) End If Next Next For i = 2 To 12 东南大部 If i < 9 Then a2 = a2 + Cells(i, 2) b2 = b2 + Cells(i, 3) c2 = c2 + Cells(i, 5) d2 = d2 + Cells(i, 6) e2 = e2 + Cells(i, 8) f2 = f2 + Cells(i, 10) End If 接通量 Cells(13, 2) = a2 接听量 Cells(13, 3) = b2 接听率 Cells(13, 4) = b2 / a2 400商机量 Cells(13, 5) = c2 转录入量 Cells(13, 6) = d2 转录入率 Cells(13, 7) = d2 / c2 转带看量 Cells(13, 8) = e2 转带看率 Cells(13, 9) = e2 / c2 转成交量 Cells(13, 10) = f2 转成交率 Cells(13, 11) = f2 / c2 西北大部 If i > 8 Then a1 = a1 + Cells(i, 2) b1 = b1 + Cells(i, 3) c1 = c1 + Cells(i, 5) d1 = d1 + Cells(i, 6) e1 = e1 + Cells(i, 8) f1 = f1 + Cells(i, 10) End If 接通量 Cells(14, 2) = a1 接听量 Cells(14, 3) = b1 接听率 Cells(14, 4) = b1 / a1 400商机量 Cells(14, 5) = c1 转录入量 Cells(14, 6) = d1 转录入率 Cells(14, 7) = d1 / c1 转带看量 Cells(14, 8) = e1 转带看率 Cells(14, 9) = e1 / c1 转成交量 Cells(14, 10) = f1 转成交率 Cells(14, 11) = f1 / c1 Next 公司 接通量 Cells(15, 2) = a1 + a2 接听量 Cells(15, 3) = b1 + b2 接听率 Cells(15, 4) = (b1 + b2) / (a1 + a2) 400商机量 Cells(15, 5) = c1 + c2 转录入量 Cells(15, 6) = d1 + d2 转录入率 Cells(15, 7) = (d1 + d2) / (c1 + c2) 转带看量 Cells(15, 8) = e1 + e2 转带看率 Cells(15, 9) = (e1 + e2) / (c1 + c2) 转成交量 Cells(15, 10) = f1 + f2 转成交率 Cells(15, 11) = (f1 + f2) / (c1 + c2) a1 = 0 b1 = 0 c1 = 0 d1 = 0 e1 = 0 f1 = 0 a2 = 0 b2 = 0 c2 = 0 d2 = 0 e2 = 0 f2 = 0 买卖M Sheets("买卖M").Select arr1 = Sheets("买卖M质").Range("A1:C14") arr2 = Sheets("买卖M转").Range("A1:I14") For i = 2 To 12 For j = 2 To 14 买卖M质 If Cells(i, 1) = arr1(j, 1) Then IM会话数_买卖 Cells(i, 2) = arr1(j, 2) IM1分钟响应量_买卖 Cells(i, 3) = arr1(j, 2) * arr1(j, 3) IM1分钟响应率_买卖 Cells(i, 4) = arr1(j, 3) IM商机量_买卖 Cells(i, 5) = arr2(j, 2) IM转录入量_买卖 Cells(i, 6) = arr2(j, 7) IM转录入率_买卖 Cells(i, 7) = arr2(j, 3) IM转带看量_买卖 Cells(i, 8) = arr2(j, 8) IM转带看率_买卖 Cells(i, 9) = arr2(j, 4) IM转成交量_买卖 Cells(i, 10) = arr2(j, 9) IM转成交率_买卖 Cells(i, 11) = arr2(j, 5) End If Next Next For i = 2 To 12 东南大部 If i < 9 Then a2 = a2 + Cells(i, 2) b2 = b2 + Cells(i, 3) c2 = c2 + Cells(i, 5) d2 = d2 + Cells(i, 6) e2 = e2 + Cells(i, 8) f2 = f2 + Cells(i, 10) End If IM会话数_买卖 Cells(13, 2) = a2 1分钟响应量 Cells(13, 3) = b2 1分钟响应率 Cells(13, 4) = b2 / a2 IM商机量 Cells(13, 5) = c2 转录入量 Cells(13, 6) = d2 转录入率 Cells(13, 7) = d2 / c2 转带看量 Cells(13, 8) = e2 转带看率 Cells(13, 9) = e2 / c2 转成交量 Cells(13, 10) = f2 转成交率 Cells(13, 11) = f2 / c2 西北大部 If i > 8 Then a1 = a1 + Cells(i, 2) b1 = b1 + Cells(i, 3) c1 = c1 + Cells(i, 5) d1 = d1 + Cells(i, 6) e1 = e1 + Cells(i, 8) f1 = f1 + Cells(i, 10) End If IM会话数 Cells(14, 2) = a1 1分钟响应量 Cells(14, 3) = b1 1分钟响应率 On Error Resume Next Cells(14, 4) = b1 / a1 IM商机量 Cells(14, 5) = c1 转录入量 Cells(14, 6) = d1 转录入率 Cells(14, 7) = d1 / c1 转带看量 Cells(14, 8) = e1 转带看率 Cells(14, 9) = e1 / c1 转成交量 Cells(14, 10) = f1 转成交率 Cells(14, 11) = f1 / c1 Next 公司 会话数 Cells(15, 2) = a1 + a2 1分钟响应量 Cells(15, 3) = b1 + b2 1分钟响应率 Cells(15, 4) = (b1 + b2) / (a1 + a2) IM商机量 Cells(15, 5) = c1 + c2 转录入量 Cells(15, 6) = d1 + d2 转录入率 Cells(15, 7) = (d1 + d2) / (c1 + c2) 转带看量 Cells(15, 8) = e1 + e2 转带看率 Cells(15, 9) = (e1 + e2) / (c1 + c2) 转成交量 Cells(15, 10) = f1 + f2 转成交率 Cells(15, 11) = (f1 + f2) / (c1 + c2) a1 = 0 b1 = 0 c1 = 0 d1 = 0 e1 = 0 f1 = 0 a2 = 0 b2 = 0 c2 = 0 d2 = 0 e2 = 0 f2 = 0 买卖M转录 Sheets("买卖M转录").Select arr1 = Sheets("买卖M质").Range("A1:I14") arr2 = Sheets("买卖M转").Range("A1:I14") For i = 2 To 12 For j = 2 To 14 IM质量 If Cells(i, 1) = arr1(j, 1) Then For k = 2 To 9 Cells(i, k) = arr1(j, k) Next End If 转录入 If Cells(i, 1) = arr2(j, 1) Then Cells(i, 10) = arr2(j, 3) End If Next Next Sheets("买卖总").Select arr = Sheets("买卖总转").Range("A1:I14") For i = 2 To 12 For j = 2 To 14 If Cells(i, 1) = arr(j, 1) Then 商机量 Cells(i, 2) = arr(j, 2) 转录入量 Cells(i, 3) = arr(j, 7) 转录入率 Cells(i, 4) = arr(j, 3) 转带看量 Cells(i, 5) = arr(j, 8) 转带看率 Cells(i, 6) = arr(j, 4) 转成交量 Cells(i, 7) = arr(j, 9) 转成交率 Cells(i, 8) = arr(j, 5) End If Next Next For i = 2 To 12 东南大部 If i < 9 Then a2 = a2 + Cells(i, 2) b2 = b2 + Cells(i, 3) c2 = c2 + Cells(i, 5) d2 = d2 + Cells(i, 7) End If 总商机量 Cells(13, 2) = a2 总商机转录入量 Cells(13, 3) = b2 总商机转录入率 Cells(13, 4) = b2 / a2 总商机转带看量 Cells(13, 5) = c2 总商机转带看率 Cells(13, 6) = c2 / a2 总商机转成交量 Cells(13, 7) = d2 总商机转成交率 Cells(13, 8) = d2 / a2 西北大部 If i > 8 Then a1 = a1 + Cells(i, 2) b1 = b1 + Cells(i, 3) c1 = c1 + Cells(i, 5) d1 = d1 + Cells(i, 7) End If 总商机量 Cells(14, 2) = a1 总商机转录入量 Cells(14, 3) = b1 总商机转录入率 On Error Resume Next Cells(14, 4) = b1 / a1 总商机转带看量 Cells(14, 5) = c1 总商机转带看率 Cells(14, 6) = c1 / a1 总商机转成交量 Cells(14, 7) = d1 总商机转成交率 Cells(14, 8) = d1 / a1 Next 公司 总商机量 Cells(15, 2) = a1 + a2 总商机转录入量 Cells(15, 3) = b1 + b2 总商机转录入率 Cells(15, 4) = (b1 + b2) / (a1 + a2) 总商机转带看量 Cells(15, 5) = c1 + c2 总商机转带看率 Cells(15, 6) = (c1 + c2) / (a1 + a2) 总商机转成交量 Cells(15, 7) = d1 + d2 总商机转成交率 Cells(15, 8) = (d1 + d2) / (a1 + a2) a1 = 0 b1 = 0 c1 = 0 d1 = 0 e1 = 0 f1 = 0 a2 = 0 b2 = 0 c2 = 0 d2 = 0 e2 = 0 f2 = 0 Sheets("新4").Select 新4 arr1 = Sheets("新4质").Range("A1:D14") arr2 = Sheets("新4转").Range("A1:I14") For i = 2 To 12 For j = 2 To 14 买卖4质 If Cells(i, 1) = arr1(j, 1) Then 400接通量_新房 Cells(i, 2) = arr1(j, 2) * arr1(j, 4) 400接听量_新房 Cells(i, 3) = arr1(j, 2) * arr1(j, 4) * arr1(j, 3) 400接听率_新房 On Error Resume Next Cells(i, 4) = Cells(i, 3) / Cells(i, 2) End If 买卖4转 If Cells(i, 1) = arr2(j, 1) Then 400商机量_新房 Cells(i, 5) = arr2(j, 2) 400转录入量 Cells(i, 6) = arr2(j, 7) 400转录入率 Cells(i, 7) = arr2(j, 3) 400转带看量 Cells(i, 8) = arr2(j, 8) 400转带看率 Cells(i, 9) = arr2(j, 4) 400转成交量 Cells(i, 10) = arr2(j, 9) 400转成交率 Cells(i, 11) = arr2(j, 5) End If Next Next For i = 2 To 12 东南大部 If i < 9 Then a2 = a2 + Cells(i, 2) b2 = b2 + Cells(i, 3) c2 = c2 + Cells(i, 5) d2 = d2 + Cells(i, 6) e2 = e2 + Cells(i, 8) f2 = f2 + Cells(i, 10) End If 接通量 Cells(13, 2) = a2 接听量 Cells(13, 3) = b2 接听率 Cells(13, 4) = b2 / a2 400商机量 Cells(13, 5) = c2 转录入量 Cells(13, 6) = d2 转录入率 Cells(13, 7) = d2 / c2 转带看量 Cells(13, 8) = e2 转带看率 Cells(13, 9) = e2 / c2 转成交量 Cells(13, 10) = f2 转成交率 Cells(13, 11) = f2 / c2 西北大部 If i > 8 Then a1 = a1 + Cells(i, 2) b1 = b1 + Cells(i, 3) c1 = c1 + Cells(i, 5) d1 = d1 + Cells(i, 6) e1 = e1 + Cells(i, 8) f1 = f1 + Cells(i, 10) End If 接通量 Cells(14, 2) = a1 接听量 Cells(14, 3) = b1 接听率 Cells(14, 4) = b1 / a1 400商机量 Cells(14, 5) = c1 转录入量 Cells(14, 6) = d1 转录入率 Cells(14, 7) = d1 / c1 转带看量 Cells(14, 8) = e1 转带看率 Cells(14, 9) = e1 / c1 转成交量 Cells(14, 10) = f1 转成交率 Cells(14, 11) = f1 / c1 Next 公司 接通量 Cells(15, 2) = a1 + a2 接听量 Cells(15, 3) = b1 + b2 接听率 Cells(15, 4) = (b1 + b2) / (a1 + a2) 400商机量 Cells(15, 5) = c1 + c2 转录入量 Cells(15, 6) = d1 + d2 转录入率 Cells(15, 7) = (d1 + d2) / (c1 + c2) 转带看量 Cells(15, 8) = e1 + e2 转带看率 Cells(15, 9) = (e1 + e2) / (c1 + c2) 转成交量 Cells(15, 10) = f1 + f2 转成交率 Cells(15, 11) = (f1 + f2) / (c1 + c2) a1 = 0 b1 = 0 c1 = 0 d1 = 0 e1 = 0 f1 = 0 a2 = 0 b2 = 0 c2 = 0 d2 = 0 e2 = 0 f2 = 0 Sheets("新M").Select 新M arr1 = Sheets("新M质").Range("A1:C14") arr2 = Sheets("新M转").Range("A1:I14") For i = 2 To 12 For j = 2 To 14 买卖M质 If Cells(i, 1) = arr1(j, 1) Then IM会话数_新房 Cells(i, 2) = arr1(j, 2) IM1分钟响应量_新房 Cells(i, 3) = arr1(j, 2) * arr1(j, 3) IM1分钟响应率_新房 Cells(i, 4) = arr1(j, 3) IM商机量_新房 Cells(i, 5) = arr2(j, 2) IM转录入量_新房 Cells(i, 6) = arr2(j, 7) IM转录入率_新房 Cells(i, 7) = arr2(j, 3) IM转带看量_新房 Cells(i, 8) = arr2(j, 8) IM转带看率_新房 Cells(i, 9) = arr2(j, 4) IM转成交量_新房 Cells(i, 10) = arr2(j, 9) IM转成交率_新房 Cells(i, 11) = arr2(j, 5) End If Next Next For i = 2 To 12 东南大部 If i < 9 Then a2 = a2 + Cells(i, 2) b2 = b2 + Cells(i, 3) c2 = c2 + Cells(i, 5) d2 = d2 + Cells(i, 6) e2 = e2 + Cells(i, 8) f2 = f2 + Cells(i, 10) End If IM会话数_买卖 Cells(13, 2) = a2 1分钟响应量 Cells(13, 3) = b2 1分钟响应率 Cells(13, 4) = b2 / a2 IM商机量 Cells(13, 5) = c2 转录入量 Cells(13, 6) = d2 转录入率 Cells(13, 7) = d2 / c2 转带看量 Cells(13, 8) = e2 转带看率 Cells(13, 9) = e2 / c2 转成交量 Cells(13, 10) = f2 转成交率 Cells(13, 11) = f2 / c2 西北大部 If i > 8 Then a1 = a1 + Cells(i, 2) b1 = b1 + Cells(i, 3) c1 = c1 + Cells(i, 5) d1 = d1 + Cells(i, 6) e1 = e1 + Cells(i, 8) f1 = f1 + Cells(i, 10) End If IM会话数 Cells(14, 2) = a1 1分钟响应量 Cells(14, 3) = b1 1分钟响应率 On Error Resume Next Cells(14, 4) = b1 / a1 IM商机量 Cells(14, 5) = c1 转录入量 Cells(14, 6) = d1 转录入率 Cells(14, 7) = d1 / c1 转带看量 Cells(14, 8) = e1 转带看率 Cells(14, 9) = e1 / c1 转成交量 Cells(14, 10) = f1 转成交率 Cells(14, 11) = f1 / c1 Next 公司 会话数 Cells(15, 2) = a1 + a2 1分钟响应量 Cells(15, 3) = b1 + b2 1分钟响应率 Cells(15, 4) = (b1 + b2) / (a1 + a2) IM商机量 Cells(15, 5) = c1 + c2 转录入量 Cells(15, 6) = d1 + d2 转录入率 Cells(15, 7) = (d1 + d2) / (c1 + c2) 转带看量 Cells(15, 8) = e1 + e2 转带看率 Cells(15, 9) = (e1 + e2) / (c1 + c2) 转成交量 Cells(15, 10) = f1 + f2 转成交率 Cells(15, 11) = (f1 + f2) / (c1 + c2) a1 = 0 b1 = 0 c1 = 0 d1 = 0 e1 = 0 f1 = 0 a2 = 0 b2 = 0 c2 = 0 d2 = 0 e2 = 0 f2 = 0 格式 Sheets("买卖4").Select 转带看率排序 Range("A1:K12").Select ActiveWorkbook.ActiveSheet.Sort.SortFields.Clear ActiveWorkbook.ActiveSheet.Sort.SortFields.Add2 Key:=Range("I2:I12") _ , SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:=xlSortNormal With ActiveWorkbook.ActiveSheet.Sort .SetRange Range("A1:K12") .Apply End With 400接听率率条件格式 Range("d2:d12").Select Selection.FormatConditions.AddColorScale ColorScaleType:=3 Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority Selection.FormatConditions(1).ColorScaleCriteria(1).Type = _ xlConditionValueLowestValue With Selection.FormatConditions(1).ColorScaleCriteria(1).FormatColor .Color = 7039480 .TintAndShade = 0 End With Selection.FormatConditions(1).ColorScaleCriteria(2).Type = _ xlConditionValuePercentile Selection.FormatConditions(1).ColorScaleCriteria(2).Value = 50 With Selection.FormatConditions(1).ColorScaleCriteria(2).FormatColor .Color = 8711167 .TintAndShade = 0 End With Selection.FormatConditions(1).ColorScaleCriteria(3).Type = _ xlConditionValueHighestValue With Selection.FormatConditions(1).ColorScaleCriteria(3).FormatColor .Color = 8109667 .TintAndShade = 0 End With 转录入率条件格式 Range("g2:g12").Select Selection.FormatConditions.AddColorScale ColorScaleType:=3 Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority Selection.FormatConditions(1).ColorScaleCriteria(1).Type = _ xlConditionValueLowestValue With Selection.FormatConditions(1).ColorScaleCriteria(1).FormatColor .Color = 7039480 .TintAndShade = 0 End With Selection.FormatConditions(1).ColorScaleCriteria(2).Type = _ xlConditionValuePercentile Selection.FormatConditions(1).ColorScaleCriteria(2).Value = 50 With Selection.FormatConditions(1).ColorScaleCriteria(2).FormatColor .Color = 8711167 .TintAndShade = 0 End With Selection.FormatConditions(1).ColorScaleCriteria(3).Type = _ xlConditionValueHighestValue With Selection.FormatConditions(1).ColorScaleCriteria(3).FormatColor .Color = 8109667 .TintAndShade = 0 End With 转带看率条件格式 Range("i2:i12").Select Selection.FormatConditions.AddColorScale ColorScaleType:=3 Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority Selection.FormatConditions(1).ColorScaleCriteria(1).Type = _ xlConditionValueLowestValue With Selection.FormatConditions(1).ColorScaleCriteria(1).FormatColor .Color = 7039480 .TintAndShade = 0 End With Selection.FormatConditions(1).ColorScaleCriteria(2).Type = _ xlConditionValuePercentile Selection.FormatConditions(1).ColorScaleCriteria(2).Value = 50 With Selection.FormatConditions(1).ColorScaleCriteria(2).FormatColor .Color = 8711167 .TintAndShade = 0 End With Selection.FormatConditions(1).ColorScaleCriteria(3).Type = _ xlConditionValueHighestValue With Selection.FormatConditions(1).ColorScaleCriteria(3).FormatColor .Color = 8109667 .TintAndShade = 0 End With 转成交率条件格式 Range("k2:k12").Select Selection.FormatConditions.AddColorScale ColorScaleType:=3 Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority Selection.FormatConditions(1).ColorScaleCriteria(1).Type = _ xlConditionValueLowestValue With Selection.FormatConditions(1).ColorScaleCriteria(1).FormatColor .Color = 7039480 .TintAndShade = 0 End With Selection.FormatConditions(1).ColorScaleCriteria(2).Type = _ xlConditionValuePercentile Selection.FormatConditions(1).ColorScaleCriteria(2).Value = 50 With Selection.FormatConditions(1).ColorScaleCriteria(2).FormatColor .Color = 8711167 .TintAndShade = 0 End With Selection.FormatConditions(1).ColorScaleCriteria(3).Type = _ xlConditionValueHighestValue With Selection.FormatConditions(1).ColorScaleCriteria(3).FormatColor .Color = 8109667 .TintAndShade = 0 End With Sheets("买卖M").Select 转带看率排序 Range("A1:K12").Select ActiveWorkbook.ActiveSheet.Sort.SortFields.Clear ActiveWorkbook.ActiveSheet.Sort.SortFields.Add2 Key:=Range("I2:I12"), _ SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:=xlSortNormal With ActiveWorkbook.ActiveSheet.Sort .SetRange Range("A1:K12") .Apply End With IM1分钟响应率条件格式 Range("d2:d12").Select Selection.FormatConditions.AddColorScale ColorScaleType:=3 Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority Selection.FormatConditions(1).ColorScaleCriteria(1).Type = _ xlConditionValueLowestValue With Selection.FormatConditions(1).ColorScaleCriteria(1).FormatColor .Color = 7039480 .TintAndShade = 0 End With Selection.FormatConditions(1).ColorScaleCriteria(2).Type = _ xlConditionValuePercentile Selection.FormatConditions(1).ColorScaleCriteria(2).Value = 50 With Selection.FormatConditions(1).ColorScaleCriteria(2).FormatColor .Color = 8711167 .TintAndShade = 0 End With Selection.FormatConditions(1).ColorScaleCriteria(3).Type = _ xlConditionValueHighestValue With Selection.FormatConditions(1).ColorScaleCriteria(3).FormatColor .Color = 8109667 .TintAndShade = 0 End With IM1转录入率条件格式 Range("g2:g12").Select Selection.FormatConditions.AddColorScale ColorScaleType:=3 Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority Selection.FormatConditions(1).ColorScaleCriteria(1).Type = _ xlConditionValueLowestValue With Selection.FormatConditions(1).ColorScaleCriteria(1).FormatColor .Color = 7039480 .TintAndShade = 0 End With Selection.FormatConditions(1).ColorScaleCriteria(2).Type = _ xlConditionValuePercentile Selection.FormatConditions(1).ColorScaleCriteria(2).Value = 50 With Selection.FormatConditions(1).ColorScaleCriteria(2).FormatColor .Color = 8711167 .TintAndShade = 0 End With Selection.FormatConditions(1).ColorScaleCriteria(3).Type = _ xlConditionValueHighestValue With Selection.FormatConditions(1).ColorScaleCriteria(3).FormatColor .Color = 8109667 .TintAndShade = 0 End With IM1转带看率条件格式 Range("i2:i12").Select Selection.FormatConditions.AddColorScale ColorScaleType:=3 Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority Selection.FormatConditions(1).ColorScaleCriteria(1).Type = _ xlConditionValueLowestValue With Selection.FormatConditions(1).ColorScaleCriteria(1).FormatColor .Color = 7039480 .TintAndShade = 0 End With Selection.FormatConditions(1).ColorScaleCriteria(2).Type = _ xlConditionValuePercentile Selection.FormatConditions(1).ColorScaleCriteria(2).Value = 50 With Selection.FormatConditions(1).ColorScaleCriteria(2).FormatColor .Color = 8711167 .TintAndShade = 0 End With Selection.FormatConditions(1).ColorScaleCriteria(3).Type = _ xlConditionValueHighestValue With Selection.FormatConditions(1).ColorScaleCriteria(3).FormatColor .Color = 8109667 .TintAndShade = 0 End With IM1转成交率条件格式 Range("k2:k12").Select Selection.FormatConditions.AddColorScale ColorScaleType:=3 Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority Selection.FormatConditions(1).ColorScaleCriteria(1).Type = _ xlConditionValueLowestValue With Selection.FormatConditions(1).ColorScaleCriteria(1).FormatColor .Color = 7039480 .TintAndShade = 0 End With Selection.FormatConditions(1).ColorScaleCriteria(2).Type = _ xlConditionValuePercentile Selection.FormatConditions(1).ColorScaleCriteria(2).Value = 50 With Selection.FormatConditions(1).ColorScaleCriteria(2).FormatColor .Color = 8711167 .TintAndShade = 0 End With Selection.FormatConditions(1).ColorScaleCriteria(3).Type = _ xlConditionValueHighestValue With Selection.FormatConditions(1).ColorScaleCriteria(3).FormatColor .Color = 8109667 .TintAndShade = 0 End With Sheets("买卖M转录").Select 3日内复聊率 Range("A1:K12").Select ActiveWorkbook.ActiveSheet.Sort.SortFields.Clear ActiveWorkbook.ActiveSheet.Sort.SortFields.Add2 Key:=Range("I2:I12") _ , SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:=xlSortNormal With ActiveWorkbook.ActiveSheet.Sort .SetRange Range("A1:K12") .Apply End With Range("H2:H12").Select Selection.FormatConditions.AddColorScale ColorScaleType:=3 Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority Selection.FormatConditions(1).ColorScaleCriteria(1).Type = _ xlConditionValueLowestValue With Selection.FormatConditions(1).ColorScaleCriteria(1).FormatColor .Color = 7039480 .TintAndShade = 0 End With Selection.FormatConditions(1).ColorScaleCriteria(2).Type = _ xlConditionValuePercentile Selection.FormatConditions(1).ColorScaleCriteria(2).Value = 50 With Selection.FormatConditions(1).ColorScaleCriteria(2).FormatColor .Color = 8711167 .TintAndShade = 0 End With Selection.FormatConditions(1).ColorScaleCriteria(3).Type = _ xlConditionValueHighestValue With Selection.FormatConditions(1).ColorScaleCriteria(3).FormatColor .Color = 8109667 .TintAndShade = 0 End With Range("I2:I12").Select Selection.FormatConditions.AddColorScale ColorScaleType:=3 Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority Selection.FormatConditions(1).ColorScaleCriteria(1).Type = _ xlConditionValueLowestValue With Selection.FormatConditions(1).ColorScaleCriteria(1).FormatColor .Color = 7039480 .TintAndShade = 0 End With Selection.FormatConditions(1).ColorScaleCriteria(2).Type = _ xlConditionValuePercentile Selection.FormatConditions(1).ColorScaleCriteria(2).Value = 50 With Selection.FormatConditions(1).ColorScaleCriteria(2).FormatColor .Color = 8711167 .TintAndShade = 0 End With Selection.FormatConditions(1).ColorScaleCriteria(3).Type = _ xlConditionValueHighestValue With Selection.FormatConditions(1).ColorScaleCriteria(3).FormatColor .Color = 8109667 .TintAndShade = 0 End With Range("J2:J12").Select Selection.FormatConditions.AddColorScale ColorScaleType:=3 Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority Selection.FormatConditions(1).ColorScaleCriteria(1).Type = _ xlConditionValueLowestValue With Selection.FormatConditions(1).ColorScaleCriteria(1).FormatColor .Color = 7039480 .TintAndShade = 0 End With Selection.FormatConditions(1).ColorScaleCriteria(2).Type = _ xlConditionValuePercentile Selection.FormatConditions(1).ColorScaleCriteria(2).Value = 50 With Selection.FormatConditions(1).ColorScaleCriteria(2).FormatColor .Color = 8711167 .TintAndShade = 0 End With Selection.FormatConditions(1).ColorScaleCriteria(3).Type = _ xlConditionValueHighestValue With Selection.FormatConditions(1).ColorScaleCriteria(3).FormatColor .Color = 8109667 .TintAndShade = 0 End With Sheets("买卖总").Select 转带看率排序 Range("A1:H12").Select ActiveWorkbook.ActiveSheet.Sort.SortFields.Clear ActiveWorkbook.ActiveSheet.Sort.SortFields.Add2 Key:=Range("F2:F12"), _ SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:=xlSortNormal With ActiveWorkbook.ActiveSheet.Sort .SetRange Range("A1:H12") .Apply End With 转录入率条件格式 Range("D2:D12").Select Selection.FormatConditions.AddColorScale ColorScaleType:=3 Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority Selection.FormatConditions(1).ColorScaleCriteria(1).Type = _ xlConditionValueLowestValue With Selection.FormatConditions(1).ColorScaleCriteria(1).FormatColor .Color = 7039480 .TintAndShade = 0 End With Selection.FormatConditions(1).ColorScaleCriteria(2).Type = _ xlConditionValuePercentile Selection.FormatConditions(1).ColorScaleCriteria(2).Value = 50 With Selection.FormatConditions(1).ColorScaleCriteria(2).FormatColor .Color = 8711167 .TintAndShade = 0 End With Selection.FormatConditions(1).ColorScaleCriteria(3).Type = _ xlConditionValueHighestValue With Selection.FormatConditions(1).ColorScaleCriteria(3).FormatColor .Color = 8109667 .TintAndShade = 0 End With IM1转带看率条件格式 Range("F2:F12").Select Selection.FormatConditions.AddColorScale ColorScaleType:=3 Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority Selection.FormatConditions(1).ColorScaleCriteria(1).Type = _ xlConditionValueLowestValue With Selection.FormatConditions(1).ColorScaleCriteria(1).FormatColor .Color = 7039480 .TintAndShade = 0 End With Selection.FormatConditions(1).ColorScaleCriteria(2).Type = _ xlConditionValuePercentile Selection.FormatConditions(1).ColorScaleCriteria(2).Value = 50 With Selection.FormatConditions(1).ColorScaleCriteria(2).FormatColor .Color = 8711167 .TintAndShade = 0 End With Selection.FormatConditions(1).ColorScaleCriteria(3).Type = _ xlConditionValueHighestValue With Selection.FormatConditions(1).ColorScaleCriteria(3).FormatColor .Color = 8109667 .TintAndShade = 0 End With 转成交率条件格式 Range("H2:H12").Select Selection.FormatConditions.AddColorScale ColorScaleType:=3 Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority Selection.FormatConditions(1).ColorScaleCriteria(1).Type = _ xlConditionValueLowestValue With Selection.FormatConditions(1).ColorScaleCriteria(1).FormatColor .Color = 7039480 .TintAndShade = 0 End With Selection.FormatConditions(1).ColorScaleCriteria(2).Type = _ xlConditionValuePercentile Selection.FormatConditions(1).ColorScaleCriteria(2).Value = 50 With Selection.FormatConditions(1).ColorScaleCriteria(2).FormatColor .Color = 8711167 .TintAndShade = 0 End With Selection.FormatConditions(1).ColorScaleCriteria(3).Type = _ xlConditionValueHighestValue With Selection.FormatConditions(1).ColorScaleCriteria(3).FormatColor .Color = 8109667 .TintAndShade = 0 End With Sheets("新4").Select 转带看率排序 Range("A1:K12").Select ActiveWorkbook.ActiveSheet.Sort.SortFields.Clear ActiveWorkbook.ActiveSheet.Sort.SortFields.Add2 Key:=Range("I2:I12") _ , SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:=xlSortNormal With ActiveWorkbook.ActiveSheet.Sort .SetRange Range("A1:K12") .Apply End With 400接听率率条件格式 Range("d2:d12").Select Selection.FormatConditions.AddColorScale ColorScaleType:=3 Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority Selection.FormatConditions(1).ColorScaleCriteria(1).Type = _ xlConditionValueLowestValue With Selection.FormatConditions(1).ColorScaleCriteria(1).FormatColor .Color = 7039480 .TintAndShade = 0 End With Selection.FormatConditions(1).ColorScaleCriteria(2).Type = _ xlConditionValuePercentile Selection.FormatConditions(1).ColorScaleCriteria(2).Value = 50 With Selection.FormatConditions(1).ColorScaleCriteria(2).FormatColor .Color = 8711167 .TintAndShade = 0 End With Selection.FormatConditions(1).ColorScaleCriteria(3).Type = _ xlConditionValueHighestValue With Selection.FormatConditions(1).ColorScaleCriteria(3).FormatColor .Color = 8109667 .TintAndShade = 0 End With 转录入率条件格式 Range("g2:g12").Select Selection.FormatConditions.AddColorScale ColorScaleType:=3 Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority Selection.FormatConditions(1).ColorScaleCriteria(1).Type = _ xlConditionValueLowestValue With Selection.FormatConditions(1).ColorScaleCriteria(1).FormatColor .Color = 7039480 .TintAndShade = 0 End With Selection.FormatConditions(1).ColorScaleCriteria(2).Type = _ xlConditionValuePercentile Selection.FormatConditions(1).ColorScaleCriteria(2).Value = 50 With Selection.FormatConditions(1).ColorScaleCriteria(2).FormatColor .Color = 8711167 .TintAndShade = 0 End With Selection.FormatConditions(1).ColorScaleCriteria(3).Type = _ xlConditionValueHighestValue With Selection.FormatConditions(1).ColorScaleCriteria(3).FormatColor .Color = 8109667 .TintAndShade = 0 End With 转带看率条件格式 Range("i2:i12").Select Selection.FormatConditions.AddColorScale ColorScaleType:=3 Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority Selection.FormatConditions(1).ColorScaleCriteria(1).Type = _ xlConditionValueLowestValue With Selection.FormatConditions(1).ColorScaleCriteria(1).FormatColor .Color = 7039480 .TintAndShade = 0 End With Selection.FormatConditions(1).ColorScaleCriteria(2).Type = _ xlConditionValuePercentile Selection.FormatConditions(1).ColorScaleCriteria(2).Value = 50 With Selection.FormatConditions(1).ColorScaleCriteria(2).FormatColor .Color = 8711167 .TintAndShade = 0 End With Selection.FormatConditions(1).ColorScaleCriteria(3).Type = _ xlConditionValueHighestValue With Selection.FormatConditions(1).ColorScaleCriteria(3).FormatColor .Color = 8109667 .TintAndShade = 0 End With 转成交率条件格式 Range("k2:k12").Select Selection.FormatConditions.AddColorScale ColorScaleType:=3 Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority Selection.FormatConditions(1).ColorScaleCriteria(1).Type = _ xlConditionValueLowestValue With Selection.FormatConditions(1).ColorScaleCriteria(1).FormatColor .Color = 7039480 .TintAndShade = 0 End With Selection.FormatConditions(1).ColorScaleCriteria(2).Type = _ xlConditionValuePercentile Selection.FormatConditions(1).ColorScaleCriteria(2).Value = 50 With Selection.FormatConditions(1).ColorScaleCriteria(2).FormatColor .Color = 8711167 .TintAndShade = 0 End With Selection.FormatConditions(1).ColorScaleCriteria(3).Type = _ xlConditionValueHighestValue With Selection.FormatConditions(1).ColorScaleCriteria(3).FormatColor .Color = 8109667 .TintAndShade = 0 End With Sheets("新M").Select Range("A1:K12").Select ActiveWorkbook.ActiveSheet.Sort.SortFields.Clear ActiveWorkbook.ActiveSheet.Sort.SortFields.Add2 Key:=Range("D2:D12"), _ SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:=xlSortNormal With ActiveWorkbook.ActiveSheet.Sort .SetRange Range("A1:K12") .Apply End With IM响应率_新房条件格式 Range("D2:D12").Select Selection.FormatConditions.AddColorScale ColorScaleType:=3 Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority Selection.FormatConditions(1).ColorScaleCriteria(1).Type = _ xlConditionValueLowestValue With Selection.FormatConditions(1).ColorScaleCriteria(1).FormatColor .Color = 7039480 .TintAndShade = 0 End With Selection.FormatConditions(1).ColorScaleCriteria(2).Type = _ xlConditionValuePercentile Selection.FormatConditions(1).ColorScaleCriteria(2).Value = 50 With Selection.FormatConditions(1).ColorScaleCriteria(2).FormatColor .Color = 8711167 .TintAndShade = 0 End With Selection.FormatConditions(1).ColorScaleCriteria(3).Type = _ xlConditionValueHighestValue With Selection.FormatConditions(1).ColorScaleCriteria(3).FormatColor .Color = 8109667 .TintAndShade = 0 End With IM加私率_新房条件格式 Range("G2:G12").Select Selection.FormatConditions.AddColorScale ColorScaleType:=3 Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority Selection.FormatConditions(1).ColorScaleCriteria(1).Type = _ xlConditionValueLowestValue With Selection.FormatConditions(1).ColorScaleCriteria(1).FormatColor .Color = 7039480 .TintAndShade = 0 End With Selection.FormatConditions(1).ColorScaleCriteria(2).Type = _ xlConditionValuePercentile Selection.FormatConditions(1).ColorScaleCriteria(2).Value = 50 With Selection.FormatConditions(1).ColorScaleCriteria(2).FormatColor .Color = 8711167 .TintAndShade = 0 End With Selection.FormatConditions(1).ColorScaleCriteria(3).Type = _ xlConditionValueHighestValue With Selection.FormatConditions(1).ColorScaleCriteria(3).FormatColor .Color = 8109667 .TintAndShade = 0 End With IM转带看率_新房条件格式 Range("i2:i12").Select Selection.FormatConditions.AddColorScale ColorScaleType:=3 Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority Selection.FormatConditions(1).ColorScaleCriteria(1).Type = _ xlConditionValueLowestValue With Selection.FormatConditions(1).ColorScaleCriteria(1).FormatColor .Color = 7039480 .TintAndShade = 0 End With Selection.FormatConditions(1).ColorScaleCriteria(2).Type = _ xlConditionValuePercentile Selection.FormatConditions(1).ColorScaleCriteria(2).Value = 50 With Selection.FormatConditions(1).ColorScaleCriteria(2).FormatColor .Color = 8711167 .TintAndShade = 0 End With Selection.FormatConditions(1).ColorScaleCriteria(3).Type = _ xlConditionValueHighestValue With Selection.FormatConditions(1).ColorScaleCriteria(3).FormatColor .Color = 8109667 .TintAndShade = 0 End With IM转成交率_新房条件格式 Range("k2:k12").Select Selection.FormatConditions.AddColorScale ColorScaleType:=3 Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority Selection.FormatConditions(1).ColorScaleCriteria(1).Type = _ xlConditionValueLowestValue With Selection.FormatConditions(1).ColorScaleCriteria(1).FormatColor .Color = 7039480 .TintAndShade = 0 End With Selection.FormatConditions(1).ColorScaleCriteria(2).Type = _ xlConditionValuePercentile Selection.FormatConditions(1).ColorScaleCriteria(2).Value = 50 With Selection.FormatConditions(1).ColorScaleCriteria(2).FormatColor .Color = 8711167 .TintAndShade = 0 End With Selection.FormatConditions(1).ColorScaleCriteria(3).Type = _ xlConditionValueHighestValue With Selection.FormatConditions(1).ColorScaleCriteria(3).FormatColor .Color = 8109667 .TintAndShade = 0 End With Application.DisplayAlerts = True MsgBox Timer - t End Sub

 

vba--数组,多个表中的程序合并到一起,设置为一个按钮

标签:清空   option   北大   err   head   with   scaletype   format   clear   

原文地址:https://www.cnblogs.com/pingzizhuanshu/p/11219731.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!