vba-在某列上查找数据放回所有的列和行

    Dim rngFound As Range
    Dim strFirst As String
    Set rngFound = DataMatchSht.Columns("B").Find("CNH MXI", Cells(Rows.Count, "B"), xlValues, xlWhole)
    If Not rngFound Is Nothing Then
        strFirst = rngFound.Address
        Do
             
                'Found a match
                Debug.Print "Found a match at: " & rngFound.Row & Chr(10) & _
                       "Value in column C: " & Cells(rngFound.Row, "C").Value & Chr(10) & _
                       "Value in column D: " & Cells(rngFound.Row, "D").Value
            
            Set rngFound = Columns("CNH MXI").Find(strID, rngFound, xlValues, xlWhole)
        Loop While rngFound.Address <> strFirst
    End If

 

posted @ 2022-12-21 13:46  vba是最好的语言  阅读(436)  评论(0编辑  收藏  举报