ExcelHome技术论坛

 找回密码
 免费注册

QQ登录

只需一步,快速开始

快捷登录

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

[求助]有条件格式的单元格的背景色是不是不能取得颜色代码

[复制链接]

TA的精华主题

TA的得分主题

发表于 2006-8-4 15:09 | 显示全部楼层 |阅读模式
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件       ★免费下载 ★       ★ 使用帮助

RY8LfM3w.rar (5.91 KB, 下载次数: 41)
[此贴子已经被作者于2006-8-4 15:17:31编辑过]

X3XDGapS.rar

4.38 KB, 下载次数: 36

[求助]有条件格式的单元格的背景色是不是不能取得颜色代码

TA的精华主题

TA的得分主题

发表于 2006-8-4 15:17 | 显示全部楼层

待Offce2007中的Excel是否能够解决。

TA的精华主题

TA的得分主题

发表于 2006-8-4 18:31 | 显示全部楼层

[求助]如何用VBA删除條件格式定義的行?
http://www.officefans.net/cdb/viewthread.php?tid=44804&pid=360656&page=1&sid=56f4XE#pid360656

找格式化的顏色 ( Font 及 Interior)

http://www.officefans.net/cdb/viewthread.php?tid=29249&fpage=1&highlight=%2BEmily

Function ConditionalColor(rg As Range, FormatType As String) As Long
'Returns the color index (either font or interior) of the first cell in range rg. If no _
    conditional format conditions apply, then returns the regular color of the cell. _
    FormatType is either "Font" or "Interior"
Dim cel As Range
Dim tmp As Variant
Dim boo As Boolean
Dim frmla As String, frmlaR1C1 As String, frmlaA1 As String
Dim i As Long

'Application.Volatile    'This statement required if Conditional Formatting for rg is determined by the _
    value of other cells

Set cel = rg.Cells(1, 1)
Select Case Left(LCase(FormatType), 1)
Case "f"    'Font color
    ConditionalColor = cel.Font.ColorIndex
Case Else   'Interior or highlight color
    ConditionalColor = cel.Interior.ColorIndex
End Select

If cel.FormatConditions.Count > 0 Then
    'On Error Resume Next
    With cel.FormatConditions
        For i = 1 To .Count     'Loop through the three possible format conditions for each cell
            frmla = .Item(i).Formula1
            If Left(frmla, 1) = "=" Then    'If "Formula Is", then evaluate if it is True
                'Conditional Formatting is interpreted relative to the active cell. _
                This cause the wrong results if the formula isn't restated relative to the cell containing the _
                Conditional Formatting--hence the workaround using ConvertFormula twice in a row. _
                If the function were not called using a worksheet formula, you could just activate the cell instead.
                frmlaR1C1 = Application.ConvertFormula(frmla, xlA1, xlR1C1, , ActiveCell)
                frmlaA1 = Application.ConvertFormula(frmlaR1C1, xlR1C1, xlA1, xlAbsolute, cel)
                boo = Application.Evaluate(frmlaA1)
            Else    'If "Value Is", then identify the type of comparison operator and build comparison formula
                Select Case .Item(i).Operator
                Case xlEqual  ' = x
                    frmla = cel & "=" & .Item(i).Formula1
                Case xlNotEqual ' <> x
                    frmla = cel & "<>" & .Item(i).Formula1
                Case xlBetween  'x <= cel <= y
                    frmla = "AND(" & .Item(i).Formula1 & "<=" & cel & "," & cel & "<=" & .Item(i).Formula2 & ")"
                Case xlNotBetween   'x > cel or cel > y
                    frmla = "OR(" & .Item(i).Formula1 & ">" & cel & "," & cel & ">" & .Item(i).Formula2 & ")"
                Case xlLess ' < x
                    frmla = cel & "<" & .Item(i).Formula1
                Case xlLessEqual    ' <= x
                    frmla = cel & "<=" & .Item(i).Formula1
                Case xlGreater  ' > x
                    frmla = cel & ">" & .Item(i).Formula1
                Case xlGreaterEqual ' >= x
                    frmla = cel & ">=" & .Item(i).Formula1
                End Select
                boo = Application.Evaluate(frmla)   'Evaluate the "Value Is" comparison formula
            End If
            
            If boo Then 'If this Format Condition is satisfied
                On Error Resume Next
                Select Case Left(LCase(FormatType), 1)
                Case "f"    'Font color
                    tmp = .Item(i).Font.ColorIndex
                Case Else   'Interior or highlight color
                    tmp = .Item(i).Interior.ColorIndex
                End Select
                If Err = 0 Then ConditionalColor = tmp
                Err.Clear
                On Error GoTo 0
                Exit For    'Since Format Condition is satisfied, exit the inner loop
            End If
        Next i
    End With
End If

End Function

TA的精华主题

TA的得分主题

发表于 2006-11-10 11:06 | 显示全部楼层
您需要登录后才可以回帖 登录 | 免费注册

本版积分规则

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

GMT+8, 2024-4-27 08:52 , Processed in 0.031726 second(s), 12 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 1999-2023 Wooffice Inc.

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

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

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