ExcelHome技术论坛

 找回密码
 免费注册

QQ登录

只需一步,快速开始

快捷登录

搜索
EH技术汇-专业的职场技能充电站 妙哉!函数段子手趣味讲函数 Excel服务器-会Excel,做管理系统 Excel Home精品图文教程库
HR薪酬管理数字化实战 Excel 2021函数公式学习大典 Excel数据透视表实战秘技 打造核心竞争力的职场宝典
300集Office 2010微视频教程 数据工作者的案头书 免费直播课集锦 ExcelHome出品 - VBA代码宝免费下载
用ChatGPT与VBA一键搞定Excel WPS表格从入门到精通 Excel VBA经典代码实践指南
查看: 10136|回复: 14

[求助] 根据达成率区分不同颜色的数据条

[复制链接]

TA的精华主题

TA的得分主题

发表于 2019-1-15 01:42 | 显示全部楼层 |阅读模式
本帖最后由 ruanjiand1 于 2019-1-15 23:59 编辑

根据达成率是否达标自动显示不同颜色的数据条(如图),如达成率高于100%为绿色数据条,达成率低于100%用黄色数据条,请问应该如何设置?
11.png
双色条形图教程看这里:
http://blog.sina.com.cn/s/blog_acadeb540102wiej.html
根据这个方法做出来是以下的效果哦,跟上图我想要的效果不一样呢。请问有更好的办法吗?

222.jpg

TA的精华主题

TA的得分主题

发表于 2019-1-15 13:30 | 显示全部楼层
开始--条件格式 --新建规则
只为包含以下内容的单元格设置格式

设定你想要的效果就行了

TA的精华主题

TA的得分主题

发表于 2019-1-15 14:25 | 显示全部楼层
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用  · 内置多项VBA编程加强工具       ★ 免费下载 ★      ★使用手册
顶一下,留下脚步,我也不会,条件格式,数据条,新建规则,最小值选择公式,公式里面写入,=if($D$2>=1,1,0),渐变填充,选择颜色,然后从左到右;这样可以完成>=100%的渐变数据条填充为绿色;可是黄色<1的如何完成啊,我不会啊,等其他人吧,或许最开始就是错的

TA的精华主题

TA的得分主题

发表于 2019-1-15 16:06 | 显示全部楼层

TA的精华主题

TA的得分主题

发表于 2019-1-15 16:35 | 显示全部楼层
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件       ★免费下载 ★       ★ 使用帮助
双色条形图教程看这里:
http://blog.sina.com.cn/s/blog_acadeb540102wiej.html

本例公式:=$D2<=20

TA的精华主题

TA的得分主题

发表于 2019-1-20 22:14 | 显示全部楼层
Sub 按照需求并更颜色()
Dim rg As Range
Set Rng = Application.InputBox("请输入需要变更的单元格:", , , , , , , Type:=8)
For Each rg In Rng
If rg.Value >= 1 Then
rg.Select
    Selection.FormatConditions.AddDatabar
    Selection.FormatConditions(Selection.FormatConditions.Count).ShowValue = True
    Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
    With Selection.FormatConditions(1)
        .MinPoint.Modify newtype:=xlConditionValueAutomaticMin
        .MaxPoint.Modify newtype:=xlConditionValueAutomaticMax
    End With
    With Selection.FormatConditions(1).BarColor
        .Color = 8700771
        .TintAndShade = 0
    End With
    Selection.FormatConditions(1).BarFillType = xlDataBarFillGradient
    Selection.FormatConditions(1).Direction = xlContext
    Selection.FormatConditions(1).NegativeBarFormat.ColorType = xlDataBarColor
    Selection.FormatConditions(1).BarBorder.Type = xlDataBarBorderSolid
    Selection.FormatConditions(1).NegativeBarFormat.BorderColorType = _
        xlDataBarColor
    With Selection.FormatConditions(1).BarBorder.Color
        .Color = 8700771
        .TintAndShade = 0
    End With
    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
    With Selection.FormatConditions(1).NegativeBarFormat.BorderColor
        .Color = 255
        .TintAndShade = 0
    End With
   Else
    rg.Select
    Selection.FormatConditions.AddDatabar
    Selection.FormatConditions(Selection.FormatConditions.Count).ShowValue = True
    Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
    With Selection.FormatConditions(1)
        .MinPoint.Modify newtype:=xlConditionValueAutomaticMin
        .MaxPoint.Modify newtype:=xlConditionValueAutomaticMax
    End With
    With Selection.FormatConditions(1).BarColor
        .Color = 2668287
        .TintAndShade = 0
    End With
    Selection.FormatConditions(1).BarFillType = xlDataBarFillGradient
    Selection.FormatConditions(1).Direction = xlContext
    Selection.FormatConditions(1).NegativeBarFormat.ColorType = xlDataBarColor
    Selection.FormatConditions(1).BarBorder.Type = xlDataBarBorderSolid
    Selection.FormatConditions(1).NegativeBarFormat.BorderColorType = _
        xlDataBarColor
    With Selection.FormatConditions(1).BarBorder.Color
        .Color = 2668287
        .TintAndShade = 0
    End With
    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
    With Selection.FormatConditions(1).NegativeBarFormat.BorderColor
        .Color = 255
        .TintAndShade = 0
    End With
    End If
     Next
End Sub

TA的精华主题

TA的得分主题

发表于 2019-1-20 22:14 | 显示全部楼层
看附件,代码上传

新建 Microsoft Excel 工作表.zip

17.29 KB, 下载次数: 63

评分

1

查看全部评分

TA的精华主题

TA的得分主题

 楼主| 发表于 2019-1-20 23:50 | 显示全部楼层

谢谢,但是为了实现一个颜色显示效果,要写一大堆VBA代码,这时间成本会不会太高了

TA的精华主题

TA的得分主题

发表于 2019-1-21 01:33 | 显示全部楼层

TA的精华主题

TA的得分主题

发表于 2019-1-21 01:49 | 显示全部楼层
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用  · 内置多项VBA编程加强工具       ★ 免费下载 ★      ★使用手册
照着5楼链接能做出来你可以再按教程做一遍

条件格式.JPG



您需要登录后才可以回帖 登录 | 免费注册

本版积分规则

关闭

最新热点上一条 /1 下一条

手机版|关于我们|联系我们|ExcelHome

GMT+8, 2024-4-25 20:28 , Processed in 0.041538 second(s), 13 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 1999-2023 Wooffice Inc.

沪公网安备 31011702000001号 沪ICP备11019229号-2

本论坛言论纯属发表者个人意见,任何违反国家相关法律的言论,本站将协助国家相关部门追究发言者责任!     本站特聘法律顾问:李志群律师

快速回复 返回顶部 返回列表