2016-04-25 12 views
0

を使用して重複した値に色を私は私はいくつかを達成したが、Gでのステータスが列=準備ができた場合は、まだ私はは、列の範囲から値を分割し、VBマクロ

  1. いくつかの助けを必要としているのbolow要件を持っていますすべての値は、列Cである場合は再テスト又は
  2. を通過するそして、テイク/列Cに重複IDを分割する(、)カンマで区切ら
  3. 列Aの重複IDを検索し、グリーン色で
  4. それをマーク

[![例データ] [1]] [1]

ex。欠陥ID CMS-921の行1に2つのID 44と163693が重複しているので、列Aの値を調べる必要があります。

  1. これらの欠陥(44および163693は、i)グリーン色で私の現在のコードの

例行全体をマークする必要があり、次いで閉じていない:

Sub findduplicateColorIt() 
Get the last row 
Dim Report As Worksheet 
Dim i As Integer, j As Integer 
Dim lastRow As Integer 

Set Report = Excel.Worksheets("Sheet2")          
lastRow = Report.UsedRange.Rows.Count 

Application.ScreenUpdating = False 
For i = 2 To lastRow 
For j = 2 To lastRow 
    If Report.Cells(i, 4).Value <> ""_ 
     And Report.Cells(i, 7).Value = "Ready to retest"_ 
     And Report.Cells(i, 1).Value = "Jira" Then 

'This will omit blank cells at the end 
'(in the event that the column lengths are not equal). 

     If InStr(1, Report.Cells(j, 2).Value, Report.Cells(i, 3).Value, vbTextCompare) > 0 Then 

' need to get a logic where i need to get value from Colum D, 
'split it and find the value in column A and color the row with green/any. 

      a = Split(ActiveCell.Value, ",") 
      For Text = 0 To UBound(a) 
      MsgBox a(Text) 
      Next Text 

      Exit For 
     Else 
     End If 
    End If 
Next j 
Next i 

Application.ScreenUpdating = True 

End Sub 
+0

正確に何か問題がありますか? (重複を見つける、値を分割する、forループが機能しないなど) –

+0

何もしていない 'Else'があるようです。 –

+0

@CodyG。今、配列のA =分割(ActiveCell.Value、 "、")は複数の値を持つ、今私は(i)から個々の値を取る必要がありますし、列Bで検索し、行全体を着色..私は得ることができませんその論理... – Venkat

答えて

0

ヴェンカト...論理の一例としてこれを使用。あなたはエラーを避ける/捕らえるために物を追加する必要があります、私は確信しています。

Sub findduplicateColorIt() 
Dim Report As Worksheet 
Dim a() As String 
Dim i As Long, j As Long 
Dim lastRow As Long, chkRow As Long 

Set Report = Excel.Worksheets("Sheet3") 
lastRow = Report.UsedRange.Rows.Count 

Application.ScreenUpdating = False 
For i = 2 To lastRow 
    If Report.Cells(i, 4).Value <> "" And _ 
     (InStr(Report.Cells(i, 7).Value, "Ready to retest") > 0 Or _ 
     InStr(Report.Cells(i, 7).Value, "Passed") > 0) And _ 
     InStr(Report.Cells(i, 1).Value, "JIRA") > 0 Then 'This will omit blank cells at the end (in the event that the column lengths are not equal. 

     a = Split(Report.Cells(i, 3).Value, ",") 
     For j = 0 To UBound(a) 
      chkRow = Report.Range("B1:B" & lastRow).Find(a(j)).Row 
      If chkRow > 0 Then 
       If Not InStr(Report.Cells(chkRow, 7).Value, "Closed") > 0 Then 
        Debug.Print Report.Range("A" & i).Address 
        Report.Range("A" & i).EntireRow.Interior.Color = vbGreen 
       End If 
      End If 
     Next j 
    End If 
Next i 

Application.ScreenUpdating = True 

End Sub 
+0

私が望むように働いたコードのおかげで、ちょうど以下のいくつかが変更されました chkRow = Report.Range( "B1:B"&lastRow).Find(a))行 Debug.Print Report.Range ( "B"&chkRow).Address chkRow> 0の場合 InStr(Report.Cells(chkRow、7).Value、 "Closed")> 0の場合 Debug.Print Report.Range( "A"& ( "A"&chkRow).EntireRow.Interior.Color = vbGreen End If 終了の場合 – Venkat

関連する問題