查找并找到下一个功能

时间:2019-04-23 22:50:09

标签: excel vba function

我目前正在尝试完成此功能,该功能检查另一张纸上的值,但是目前仅检查第一个值,而不检查重复项。

sheet1函数

Function Checkcollipotecaassente(row As Range)
   Dim ndg As String
   Dim loanid As String
   Dim rowindex As Integer
   ndg = extrapolatendg(row)
   rowindex = Sheet6.findrownumberndg(ndg)
   loanid = Sheet6.getloanid(rowindex)

   If Sheet7.findrownumberloan(loanid) = True Then
            If Sheet6.CheckDuplicate(ndg) = True Then
               Do
                rowindex = Sheet6.Findrownumberdg2(rowindex)
                loanid = Sheet6.getloanid(rowindex)
                Loop Until Sheet7.findrownumberloan(loanid) = False
           End If

       Checkcollipotecaassente = True
   Else
       Checkcollipotecaassente = False
   End If
End Function

sheet6函数

Function CheckDuplicate(extrapolatendg As String) As Boolean

    Set foundcell = Range("B:B").Find(extrapolatendg, lookat:=xlWhole)
    If foundcell Is Nothing Then
        CheckDuplicate = False
    Else
        adrFirst = foundcell.Address
        Set foundcell = Sheet6.Range("B:B").FindNext(foundcell)
        If foundcell.Address = adrFirst Then
            CheckDuplicate = False
        Else
            CheckDuplicate = True
        End If
    End If

End Function
Function Findrownumberdg2(findrownumberndg As Integer)

        adrFirst = foundcell.Address
        Set foundcell = Sheet6.Range("B:B").FindNext(foundcell)
        If foundcell.Address = adrFirst Then
            Findrownumberdg2 = 0
        Else
            Findrownumberdg2 = foundcell.row
        End If


End Function
Function findrownumberndg(extrapolatendg As String) As Integer


Set foundcell = Range("B:B").Find(extrapolatendg, lookat:=xlWhole)

If Not foundcell Is Nothing Then

 findrownumberndg = foundcell.row


Else

findrownumberndg = 0

End If

End Function

因此,一旦findrownumberndg在sheet6上找到行号并且checkduplicate函数找到重复项,我就需要遍历findrownumberndg2,直到findrownumberloan返回false为止,

0 个答案:

没有答案