2

Excel を使い始めて 6 年になりますが、少しさびています。これが私のシナリオです:

問題のリストを Excel にエクスポートしています。セル内の関連付けられたリンク番号 (複数の値) を互いに区別できる必要があります。例、私は2つの列を持っています、

キー = チケットの番号

リンクされた問題 = 関連するキー

Key 列をスキャンし、Linked Issues 列で一致を見つけるステートメントが必要です。次に、一致が見つかると、一致するテキストがキーのフォントの色になります。

これが複雑になるのは、Linked Issues 列の各セルが iss-3913、iss-3923、iss-1649 のように見えることです。したがって、基本的にスキャンは文字列内の一致を対象とします。どんな助けでも大歓迎です。

4

2 に答える 2

1

申し訳ありませんが、今はこれを完了する時間がありませんが、wこのようなものは役に立ちますかおそらく最初の列の各セルのループ?

編集: B5 と Z5 に更新する 2 番目の編集、列参照を使用して 3 つの固定グーフを編集し、変数を使用して検索する列を割り当てるように更新しました。

Sub colortext()
start_row = 5
key_col = 2
linked_col = 26
i = start_row 'start on row one
Do While Not IsEmpty(Cells(i, key_col)) 'Do until empty cell
    o = start_row 'start with row one for second column
    Do While Not IsEmpty(Cells(o, linked_col)) 'Do until empty cell
    If Not InStr(1, Cells(o, linked_col), Cells(i, key_col)) = 0 Then  'if cell contents found in cell
        With Cells(o, linked_col).Characters(Start:=InStr(1, Cells(o, linked_col), Cells(i, key_col)), Length:=Len(Cells(i, key_col))).Font
            .Color = Cells(i, key_col).Font.Color  'change color of this part of the cell
        End With
    End If
    o = o + 1 'increment the cell in second column
    Loop
    i = i + 1 'increment the cell in the first column
Loop
End Sub

または多分

このようなもの?

Excel VBA:セル範囲内の特定の文字のフォントの色を変更する

于 2013-08-01T20:43:28.953 に答える
1

これは古い投稿ですが、私が抱えていた条件付き書式の問題を回避できると思いました。

Sub colorkey()
start_row = 5
key_col = 2
flag_col = 4

i = start_row 'start on row one

  Do While Not IsEmpty(Cells(i, key_col)) 'Do until empty cell

  Tval = Cells(i, flag_col).Value
    Select Case Tval
    Case "Requirement"
        'cval = green
        cVal = 10
    Case "New Feature"
        'cval = orange
        cVal = 46
    Case "Test"
        'cval = lt blue
        cVal = 28
    Case "Epic"
        'cval = maroon
        cVal = 30
    Case "Story"
        'cval = dk blue
        cVal = 49
    Case "Theme"
        'cval = grey
        cVal = 48
    Case "Bug"
        'cval = red
        cVal = 3
    Case "NOT MAPPED"
        'cval = Maroon
        cVal = 1
    End Select


Cells(i, key_col).Font.ColorIndex = cVal

    i = i + 1 'increment the cell in the first column
    Loop

End Sub
Sub colorlinked()
start_row = 5
key_col = 2
linked_col = 26
i = start_row 'start on row one
Do While Not IsEmpty(Cells(i, key_col)) 'Do until empty cell
    o = start_row 'start with row one for second column
    Do While Not IsEmpty(Cells(o, linked_col)) 'Do until empty cell
    If Not InStr(1, Cells(o, linked_col), Cells(i, key_col)) = 0 Then  'if cell contents found in cell
        With Cells(o, linked_col).Characters(Start:=InStr(1, Cells(o, linked_col), Cells(i, key_col)), Length:=Len(Cells(i, key_col))).Font
            .Color = Cells(i, key_col).Font.Color  'change color of this part of the cell
        End With
    End If
    o = o + 1 'increment the cell in second column
    Loop
    i = i + 1 'increment the cell in the first column
Loop
MsgBox "Finished Scanning"
End Sub
于 2014-08-15T18:35:11.313 に答える