advanced help
per page, with , order by , clip by
Results of 1 - 1 of about 4503 for 条件付き書式 (0.007 sec.)
[[20190717170716]]
#score: 3704
@digest: 8ef0ef4449f2bcb4c70ed6b002a1997c
@id: 80235
@mdate: 2019-07-19T07:48:55Z
@size: 8014
@type: text/plain
#keywords: fmtcndton (70685), eachcel (50176), strfmla (47671), rngtoproc (35240), valueoffctypeexists (27823), fmtcondintrclranyver (26361), trueorfalse (23453), xlsm12 (21479), colorcnt (17052), 止条 (12773), results (12727), convertformula (11111), myclm (11091), た背 (10897), displayformat (9226), マサ (7792), 赤) (5610), 赤色 (4702), mycell (4652), result (4432), 景色 (4266), mysht (4259), 色( (4050), (赤 (4008), xlr1c1 (3725), サ) (3470), 背景 (3216), interior (3095), フセ (2951), 決定 (2734), 件付 (2238), color (2227)
条件付き書式で設定された背景色のセルをカウントする方法VBA』(マサ)
条件付き書式で設定された背景色(赤)のセルをカウントするVBAをご教授いただければ幸いです。 Function ColorCnt(rng As Range) As Double Dim RngObj As Range '指定されたセル範囲の分だけ、処理を繰り返す。 For Each RngObj In rng 'セルの色が、赤色の場合 If RngObj.Interior.Color = RGB(255, 0, 0) Then 'カウントアップする ColorCnt = ColorCnt + 1 End If Next End Function 上記ではカウントされませんでした。よろしくお願いいたします。 < 使用 Excel:Excel2016、使用 OS:Windows10 > ---- 条件付き書式でついている色も取得したいときは Range(〜).DisplayFormat.Interior.Color で。 なお、これは条件付き書式、通常の背景色の区別なしにその時点でセルに表示されている色を取得する。 (ねむねむ) 2019/07/17(水) 17:21 ---- その関数はどういった使い方をする予定でしょうか。 (マナ) 2019/07/17(水) 21:42 ---- うっかりしていた。 もしユーザー設定関数として使うのであればDisplayFormatは使えない。 これはDisplayFormatの仕様のため、どうしようもない。 (ねむねむ) 2019/07/18(木) 06:36 ---- ちょっと確認。 >条件付き書式で設定された背景色(赤) 1.赤のケースだけ決め打ちになっていますが、それでいいんですね? 2.具体的にどんな条件ですか? ※その条件でカウントする数式を作れば、色を判別しなくても対応できる可能性があります。 3.参考までにお聞きしますが、条件付き書式を設定する時、 「数式を使用して、書式設定するセルを決定」からやりましたか? (半平太) 2019/07/18(木) 07:58 ---- いつもお世話になります。 たくさんのご教授ありがとうございます。 わたしの質問の仕方が悪かったですね。 申し訳ございません。 条件付き書式で設定された背景色(赤)のセル数(列ごとに)をカウントする方法 でお願いできますでしょうか? VBAにはこだわっておりません。 よろしくお願いいたします。 (マサ) 2019/07/18(木) 10:39 ---- 条件に合うかどうか・・・ Sub test8() Dim mySht As Worksheet Dim myClm As Range Dim myCell As Range Dim i As Long Dim j As Long Set mySht = ThisWorkbook.Worksheets("Sheet3") i = 0 For Each myClm In mySht.UsedRange.Columns i = i + 1 j = 0 For Each myCell In myClm.Cells If myCell.DisplayFormat.Interior.Color = RGB(255, 0, 0) And _ myCell.Interior.Color <> RGB(255, 0, 0) Then j = j + 1 End If Next MsgBox i & "列目" & j & "個" Next End Sub (渡辺ひかる) 2019/07/18(木) 11:45 ---- いつもお世話になっております。 ご教授ありがとうございます。 A列 B列 C列 あ 赤色 赤色 い 赤色 う 赤色 赤色 え 赤色 合計 2 1 3 上記のような感じでシートがあります。 合計の欄に列の赤色の数が(条件付き書式で設定された背景色(赤))カウント(例:2、1、3)されるようにできますか。 よろしくお願いいたします。 (マサ) 2019/07/18(木) 12:04 ---- >条件付き書式で設定された背景色(赤)のセル数(列ごとに)をカウントする方法 では、これに答えていただくといいかもです。 ↓ > 3.参考までにお聞きしますが、条件付き書式を設定する時、 > 「数式を使用して、書式設定するセルを決定」からやりましたか? (半平太) 2019/07/18(木) 16:20 ---- いつもお世話になります。 ご教授ありがとうございます。 >条件付き書式で設定された背景色(赤)のセル数(列ごとに)をカウントする方法 では、これに答えていただくといいかもです。 ↓ > 3.参考までにお聞きしますが、条件付き書式を設定する時、 > 「数式を使用して、書式設定するセルを決定」からやりましたか? →「数式を使用して、書式設定するセルを決定」でやりました。 よろしくお願いいたします。 (マサ) 2019/07/19(金) 15:17 ---- >→「数式を使用して、書式設定するセルを決定」でやりました。 それなら、 1.後記マクロを標準モジュールにコピペする。 2.B5セル =SUMPRODUCT(N(FmtCondIntrCLRAnyVer(B1:B4)=255))+TODAY()*0 3.右にコピー(D5セルまで) <結果図> 行 __A__ _B_ _C_ _D_ 1 あ b c d 2 い b c d 3 う b c d 4 え b c d 5 合計 2 1 3 '標準モジュールに貼り付けるマクロ '↓ #Const xlsm12 = 12 Const msgXlExpression = "「数式を使用して・・」以外の設定有り" Public Function FmtCondIntrCLRAnyVer(rngToProc As Range) Dim rr As Long, cc As Long 'アクティブセルとのオフセット差 Dim RRR As Long, CCC As Long 'XLSM用オフセット値 Dim strFmla As String '修正後条件式 Dim TrueOrFalse As Variant Dim fmtCndton As FormatCondition Dim eachCel As Range Dim result As Long Dim Results() As Variant Dim NN As Long, MM As Long Dim rngRow As Range Set rngToProc = Intersect(rngToProc, rngToProc.Parent.UsedRange) If ValueOfFCtypeExists(rngToProc) Then '「数式を使用して・・」モードのみかチェック FmtCondIntrCLRAnyVer = msgXlExpression Exit Function End If ReDim Results(1 To rngToProc.Rows.Count, 1 To rngToProc.Columns.Count) As Variant NN = 0 For Each rngRow In rngToProc.Rows NN = NN + 1 MM = 0 For Each eachCel In rngRow.Cells rr = ActiveCell.Row - eachCel.Row cc = ActiveCell.Column - eachCel.Column MM = MM + 1 result = 0 For Each fmtCndton In eachCel.FormatConditions #If xlsm12 >= 12 Then RRR = ActiveCell.Row - fmtCndton.AppliesTo.Row CCC = ActiveCell.Column - fmtCndton.AppliesTo.Column #End If strFmla = fmtCndton.Formula1 With Application strFmla = .ConvertFormula(fmtCndton.Formula1, _ xlA1, xlR1C1, , eachCel.Offset(rr, cc)) #If xlsm12 >= 12 Then strFmla = .ConvertFormula(strFmla, _ xlR1C1, xlA1, , eachCel.Offset(RRR, CCC)) #Else strFmla = .ConvertFormula(strFmla, xlR1C1, xlA1, , eachCel) #End If End With TrueOrFalse = Evaluate(strFmla) '条件式を評価 If Not IsError(TrueOrFalse) Then If TrueOrFalse Then #If xlsm12 >= 12 Then If Not IsNull(fmtCndton.Interior.Color) Then result = fmtCndton.Interior.Color Exit For ElseIf fmtCndton.StopIfTrue Then '停止条件がTrueならこれ以上追及しない result = 0 Exit For End If #Else '停止条件不考慮(Trueになったので、いずれにしてもExitForとなる) If Not IsNull(fmtCndton.Interior.Color) Then result = fmtCndton.Interior.Color Else result = 0 End If Exit For #End If End If End If Next Results(NN, MM) = result Next Next FmtCondIntrCLRAnyVer = Results End Function Private Function ValueOfFCtypeExists(rngToProc As Range) As Boolean Dim aCell As Range Dim FC As FormatCondition ValueOfFCtypeExists = False For Each aCell In rngToProc For Each FC In aCell.FormatConditions If Not FC.Type = xlExpression Then ValueOfFCtypeExists = True Exit Function End If Next Next End Function (半平太) 2019/07/19(金) 16:48 ...
http://www.excel.studio-kazu.jp/wiki/kazuwiki/201907/20190717170716.txt - [detail] - similar
PREV NEXT
Powered by Hyper Estraier 1.4.13, with 97015 documents and 608136 words.

訪問者:カウンタValid HTML 4.01 Transitional