通过范围和if语句的excel vba循环

我需要帮助循环一个给定的范围后跟一个if语句。 我的范围是:

| A | B | C | ----------------------- |TPA | C:\ | 1.doc| |TPA | C:\ | 2.doc| |LAX | D:\ | 3.doc| 

我想通过A1:C3循环,如果A1列:A3 =“TPA”那么取B1和C1的数据。

 Dim test1 As Variant Dim cell As Range Dim cell1 As Range cell = Worksheets("Sheet2").Range ("A1:C3") cell1 = Worksheets("Sheet2").Range ("A1:A3") For Each cell1 in cell If test1 = "TPA" Then 'MsgBox B1 and C1 But I need to MsgBox B2 and C2 as well End If Next 

最终,我需要msgbox B1 + C1和B2 + C2。

未经testing….

 Dim test1 As String, c As Range, myRng As Range Dim Result as string set myRng = Worksheets("Sheet2").Range("A1:A3") For Each c in myRng If test1 = "TPA" Then Result = Result & c & c.offset(0,1) & vbCrLf End If Next c MsgBox Result