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
  • 相关阅读:
    火狐浏览器修改userAgent
    清除linux缓存命令
    linux主机间复制文件
    解决两台centos虚拟机Telnet服务无法联机的问题
    Install Redis on CentOS 6.4--转
    解决 ERROR: JDWP Transport dt_socket failed to initialize, TRANSPORT_INIT(510)异常
    主机访问虚拟机中linux上的web服务
    How can I exclude directories from grep -R?
    RPM安装命令总结--转载
    centos mongodb安装及简单实例
  • 原文地址:https://www.cnblogs.com/bigjor/p/11759871.html
Copyright © 2011-2022 走看看