我有很少的要求我已经取得了很少但仍然需要一些帮助
[![示例数据] [1]] [1]
离。在行1中,缺陷ID CMS-921有2个重复的id 44和163693.所以我需要在A列中查找这些值。
我当前代码的示例:
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 :(得分:0)
Venkat ......将此作为逻辑的一个例子。我确定你需要添加一些东西以避免/捕获错误。
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