excel vba自定义函数集合操作

方式功能:某个范围的数然后排除excel连续区域
Function isinrange(quyu As Range, xiao As Integer, da As Integer) As String
    Dim flag As Boolean
    flag = False
    For i = xiao To da
        For Each dddd In quyu
            If dddd.Value = i Then
                    flag = True
                Exit For
            End If
        Next
        If flag = False Then
            If i = da Then
                isinrange = isinrange & i
            Else
               isinrange = isinrange & i & ","
            End If
            
        End If
        flag = False
    Next
End Function




使用:=isinrange(A133:B133,1,8)
A133是4,B133是7  最终结果是 1 2 3 5 6 8

从1到8的数排除 4 7 就是结果

猜你喜欢

转载自hvang1988.iteye.com/blog/2400241