將文字檔貼至A欄,檢測有異常,在B欄以文字表示:
Sub TEST()
Dim xR As Range, T$, xH As Range, Cx
[B:B].ClearContents
For Each xR In Range([A1], Cells(Rows.Count, 1).End(xlUp))
T = Trim(xR)
If T = "(net DGND" Then Set xH = xR: ReDim Cx(3): GoTo 101
If xH Is Nothing Then GoTo 101
If InStr(xR, "portRef") Then Cx(0) = Cx(0) + 1
If T = "(portRef GND" Then Cx(1) = 1: GoTo 101
If T = "(portRef VDD" Then Cx(2) = 1: GoTo 101
If Right(T, 5) = ")))))" Then
If Val(Cx(0)) < 2 Then Cx(3) = 1
If Cx(1) + Cx(2) > 1 Then Cx(3) = 2
If Cx(3) > 0 Then Range(xH(1, 2), xR(1, 2)) = "異常(" & Cx(3) & ")"
Set xH = Nothing
End If
101: Next
End Sub