我希望代码能够找到匹配项。当识别出匹配时,查看该行中的其他单元是否符合条件。如果是,则在匹配行中替换与另一个单元格匹配的条件
Sub Find_sTRING()
Dim AG_id As String, SNL_id As String, apd As String, spd As String, AQ As String, SQ As String
Dim i As Long, Lastrow As Long, AG_sht As Worksheet
Dim x As Integer, j As Integer
'For x = 1 To nrow
'For j = 33 To ncol
'c(x, j) = AG_sht.Cells(i, j).Value ''i * 2 + j ^ 2
j = 6
x = 3
Set AG_sht = Sheets("AG")
Dim rng As Range
Lastrow = AG_sht.Range("B" & Sheets("AG").Rows.Count).End(xlUp).Row
For i = 2 To Lastrow
AG_id = AG_sht.Cells(i, "AM").Value
AQ = AG_sht.Cells(i, "E").Value
apd = AG_sht.Cells(i, "F").Value
If Trim(AG_id) <> "" Then
With Sheets("SNL").Range("H:H")
Set rng = .Find(What:=AG_id, _
After:=.Cells(.Cells.Count), _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
If Not rng Is Nothing Then
Application.Goto rng, True 'value found
If rng(Rows, j).Value = AQ And rng(Rows, x).Value = apd Then
rng = AG_id
End If
Else
i = i + 1
End If
If i = Lastrow Then
Exit For
End If
End With
End If
Next
End Sub