zoukankan      html  css  js  c++  java
  • VBA 在第二个sheet中查找第一个sheet中不存在的值

    VBA 在第二个sheet中查找第一个sheet中不存在的值
     Sub Macro2()
    '
    ' Macro2 Macro
    ' 宏由 Lizm 录制,时间: 2019/04/10
    '
     
    '
    Dim colSvcId As Integer
    Dim i As Integer
    Dim j As Integer
    j = 47
    Dim valS As String
    Dim findRes As Boolean
     
    '查找service_id
    For rowSvcId = 2 To 43
     
        valS = Range("C" & rowSvcId).Text
        
        If Len(valS) > 0 Then
            findRes = False
            
            ' 在sheet4中查找
            For i = 5 To 78
                If InStr(1, Sheets("Sheet4").Cells(i, 3).Text, valS, 1) > 0 Then
                    findRes = True
                    Exit For
                End If
            Next
            '在sheet5中查找
            For i = 4 To 22
                If InStr(1, Sheets("Sheet5").Cells(i, 3).Text, valS, 1) > 0 Then
                    findRes = True
                    Exit For
                End If
            Next
            
            
            If (findRes = False) Then
                    Sheets("Sheet3").Range("C" & j).Value = valS
                    j = j + 1
            End If
        End If
        
    Next
     
     
     
     
     
     
     
    '查找packageName(HU)
    j = 47
    For rowPkgNm = 2 To 43
        valS = Range("D" & rowPkgNm).Text
        
        If Len(valS) > 0 Then
            findRes = False
            
            ' 在sheet4中查找
            For i = 5 To 78
                If InStr(1, Sheets("Sheet4").Cells(i, 4).Text, valS, 1) > 0 Then
                    findRes = True
                    Exit For
                End If
            Next
            '在sheet5中查找
            For i = 4 To 22
                If InStr(1, Sheets("Sheet5").Cells(i, 4).Text, valS, 1) > 0 Then
                    findRes = True
                    Exit For
                End If
            Next
            
            
            If (findRes = False) Then
                    Sheets("Sheet3").Range("D" & j).Value = valS
                    j = j + 1
            End If
        End If
        
    Next
     
     
     
     
     
    '查找base_url
    j = 47
    For rowBaseUrl = 2 To 43
        valS = Range("F" & rowBaseUrl).Text
        
        If Len(valS) > 0 Then
            findRes = False
            
            ' 在sheet4中查找
            For i = 5 To 78
                If InStr(1, Sheets("Sheet4").Cells(i, 6).Text, valS, 1) > 0 Then
                    findRes = True
                    Exit For
                End If
            Next
            '在sheet5中查找
            For i = 4 To 22
                If InStr(1, Sheets("Sheet5").Cells(i, 6).Text, valS, 1) > 0 Then
                    findRes = True
                    Exit For
                End If
            Next
            
            
            If (findRes = False) Then
                    Sheets("Sheet3").Range("F" & j).Value = valS
                    j = j + 1
            End If
        End If
        
    Next
     
     
     
     
     
    '查找client
    j = 47
    For rowClient = 2 To 43
        valS = Range("G" & rowClient).Text
        
        If Len(valS) > 0 Then
            findRes = False
            
            ' 在sheet4中查找
            For i = 5 To 78
                If InStr(1, Sheets("Sheet4").Cells(i, 7).Text, valS, 1) > 0 Then
                    findRes = True
                    Exit For
                End If
            Next
            '在sheet5中查找
            For i = 4 To 22
                If InStr(1, Sheets("Sheet5").Cells(i, 7).Text, valS, 1) > 0 Then
                    findRes = True
                    Exit For
                End If
            Next
            
            
            If (findRes = False) Then
                    Sheets("Sheet3").Range("G" & j).Value = rowClient
                    j = j + 1
            End If
        End If
        
    Next
     
    End Sub
  • 相关阅读:
    DOM节点的删除(jQuery)
    DOM节点的插入(jQuery)
    DOM节点创建(jQuery)
    jQuery的属性及样式
    jQuery选择器
    jQuery对象及DOM对象
    给大家分享一个很好用的屏幕共享小软件
    Web单浏览器登录
    Winform制作圆弧panel
    Winform 无边框窗口移动自定义边框粗细颜色
  • 原文地址:https://www.cnblogs.com/bigjor/p/11759871.html
Copyright © 2011-2022 走看看