|
|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
- Sub 批量加数据条()
- Application.ScreenUpdating = False
- Dim i As Integer, j As Integer, row As Integer, temp As String
- With Sheet1
- row = .Range("a65536").End(xlUp).row
- .Range("R3").Activate
- Application.CutCopyMode = False
- .Range("R3:AA" & row).FormatConditions.Delete
- For i = 3 To row
- For j = 18 To 27
- If (.Cells(i, j - 10).Value2 <> "") Then
- temp = .Cells(i, j - 10).Value2
- Else
- temp = 0
- End If
- .Cells(i, j).Select
- Selection.FormatConditions.AddDatabar
- Selection.FormatConditions(Selection.FormatConditions.Count).ShowValue = True
- Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
- With Selection.FormatConditions(1)
- .MinPoint.Modify newtype:=xlConditionValueNumber, newvalue:=0
- .MaxPoint.Modify newtype:=xlConditionValueNumber, newvalue:=temp
- End With
- With Selection.FormatConditions(1).BarColor
- .Color = 13012579
- .TintAndShade = 0
- End With
- Selection.FormatConditions(1).BarFillType = xlDataBarFillSolid
- Selection.FormatConditions(1).Direction = xlContext
- Selection.FormatConditions(1).NegativeBarFormat.ColorType = xlDataBarColor
- Selection.FormatConditions(1).BarBorder.Type = xlDataBarBorderNone
- Selection.FormatConditions(1).AxisPosition = xlDataBarAxisAutomatic
- With Selection.FormatConditions(1).AxisColor
- .Color = 0
- .TintAndShade = 0
- End With
- With Selection.FormatConditions(1).NegativeBarFormat.Color
- .Color = 255
- .TintAndShade = 0
- End With
- Next j
- Next i
- End With
- Application.ScreenUpdating = True
- MsgBox "添加完成!!!"
- End Sub
复制代码 |
|