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
  • 相关阅读:
    策略模式c++【转】
    [转]C++设计模式:Builder模式
    c/c++ 笔试面试题
    堆排序
    冒泡,快速,和堆排序
    C++继承
    【转】林建:计算机专业学习浅谈
    (centos)linux下访问双系统windows7文件系统
    sprintf() in c
    System call in linux by C
  • 原文地址:https://www.cnblogs.com/bigjor/p/11759871.html
Copyright © 2011-2022 走看看