[[20110323104817]] 『表示』(カリン2) ページの最後に飛ぶ

[ 初めての方へ | 一覧(最新更新順) | 全文検索 | 過去ログ ]

 

『表示』(カリン2)
A9:AG200のセルに数字が入ります。
条件付き書式で赤数字になるようにしてあり
赤数字になった場合
AH列に「ABC異常」と表示させたいのです。

	AB	AC	AD	AE	AF	AG	AH
9	1	3	10(赤)	5	8	7	ABC異常
10	1	2	5	3	4	1	
11	2	2	3	3	5	5	
12	8	11	16	5	4(赤)	8	ABC異常
13							
14							
15							
16							
17							
18							
19							
20							

 お願いします。

 条件付書式で赤文字になるための条件はどんなものですか。 
 それを元にそのように表示できるかもしれません。
 (tora)


tora様

AB9
=AND(COUNT(H9,AB9)=2,H9*140%<=AB9)
が入っています。

よろしくお願いします。

(カリン2)


 ここの管理人さんが以下の関数を公開されていますので参照してみてください。

 [Color関数(関数・アドイン)]
http://www.excel.studio-kazu.jp/DL/UFClr/UFClr.html

 また、下記はMeighthさんが以前作成された関数を改良して今回の仕様に合わせて作成しました。

 Sub InColor()

    Dim maxRow As Long
    Dim iRow As Long
    Dim iCol As Integer

    maxRow = Range("A" & Columns(1).Rows.Count).End(xlUp).Row

    For iRow = 9 To maxRow
        For iCol = 1 To 33
            If GetColorRGB(Cells(iRow, iCol)) = 255 Then
                Cells(iRow, 34) = "ABC異常"
                Exit For
            Else
                Cells(iRow, 34) = ""
            End If
        Next iCol
    Next iRow

 End Sub

 Function GetColorRGB(ByVal aCell As Range) As Long
    Dim COL As Long, FC As FormatCondition, ConditionOK As Boolean
    Dim OldRefStyle As Long
    Dim f1, f2

    COL = aCell.Interior.Color

    'セル参照形式を R1C1 にする。
    OldRefStyle = Application.ReferenceStyle
    Application.ReferenceStyle = xlR1C1

    With aCell.Worksheet
        For Each FC In aCell.FormatConditions
            ConditionOK = False

            '条件付書式の Formula1 と Formula2 を取得
            f1 = """": f2 = """"""
            On Error Resume Next
            f1 = Application.ConvertFormula(FC.Formula1, xlR1C1, xlR1C1, xlAbsolute, aCell)
            f2 = Application.ConvertFormula(FC.Formula2, xlR1C1, xlR1C1, xlAbsolute, aCell)
            On Error GoTo 0

            If FC.Type = xlCellValue Then
                Select Case FC.Operator
                    Case xlEqual
                        If aCell.Value = .Evaluate(f1) Then ConditionOK = True
                    Case xlNotEqual
                        If aCell.Value <> .Evaluate(f1) Then ConditionOK = True
                    Case xlGreater
                        If aCell.Value > .Evaluate(f1) Then ConditionOK = True
                    Case xlGreaterEqual
                        If aCell.Value >= .Evaluate(f1) Then ConditionOK = True
                    Case xlLess
                        If aCell.Value < .Evaluate(f1) Then ConditionOK = True
                    Case xlLessEqual
                        If aCell.Value <= .Evaluate(f1) Then ConditionOK = True
                    Case xlBetween
                        If .Evaluate(f1) <= aCell.Value And aCell.Value <= .Evaluate(f2) Then ConditionOK = True
                    Case xlNotBetween
                        If aCell.Value < .Evaluate(f1) Or .Evaluate(f2) < aCell.Value Then ConditionOK = True
                End Select
            ElseIf FC.Type = xlExpression Then
                On Error Resume Next
                If .Evaluate(f1) Then
                    If Err.Number = 0 Then
                        ConditionOK = True
                    End If
                End If
                On Error GoTo 0
            End If

            If ConditionOK Then
                COL = FC.Font.Color
                Exit For
            End If
        Next FC
    End With

    'セル参照形式を元に戻す。
    Application.ReferenceStyle = OldRefStyle
    GetColorRGB = COL
 End Function

 (Yujin)

 例題であれば
 =IF(SUMPRODUCT((H9:M9<>"")*(H9:M9*1.4<AB9:AG9)),"ABC異常","")

 負数は考慮していません

 Yujin様
 関数の方を使わせていただきます
 ありがとうございました。

(カリン2)


コメント返信:

[ 一覧(最新更新順) ]


YukiWiki 1.6.7 Copyright (C) 2000,2001 by Hiroshi Yuki. Modified by kazu.