Case Select 在 35 个变量后太慢的问题

问题描述 投票:0回答:1

我目前根据单元格的值运行案例选择,将不同的单元格设置为“NA”(它的数据输入表),根据这个字符串,我目前有 35 个选项来检查案例选择,这太速度慢,大约需要5分钟才能找到

代码是这样的

  Dim rng As Range
    Dim cell As Range
    Dim rw As Long

'   See if any cells updated in column H (dropdown list)
    
    Set rng = Intersect(Target, Range("H:H"))
    
    If rng Is Nothing Then Exit Sub

    Application.EnableEvents = False

'   Loop through updated cells in columns I (Merge cell with combination)
    'For Each cell In rng
    For Each cell In Range("I:I")
        rw = cell.Row
        Select Case cell.Value
        
        Case "LocalElaboração_DossiêCancelamento de Registro", "LocalElaboração_DossiêCumprimento de Exigência", "LocalElaboração_DossiêDescontinuação Temporária/ Definitiva", "LocalElaboração_DossiêDesistência a pedido", "LocalElaboração_DossiêPós-registro - Notificação simplificada", "LocalElaboração_DossiêReativação de Manufatura", "LocalElaboração_DossiêRecurso", "LocalElaboração_DossiêRegistro", "LocalElaboração_DossiêRenovação", "LocalElaboração_DossiêRetificação de Publicação", "LocalElaboração_DossiêTransferência de Titularidade", "LocalElaboração_DossiêPós-registro - Paralelas", "LocalElaboração_DossiêPós-registro", "LocalElaboração_DossiêPós-registro - Concomitante", "LocalElaboração_DossiêPós-registro - Simultâneas"
            Cells(rw, "O") = "NA"
            Cells(rw, "R") = "NA"
            Cells(rw, "S") = "NA"
            Cells(rw, "U") = "NA"
            Cells(rw, "V") = "NA"
            Cells(rw, "W") = "NA"
            Cells(rw, "X") = "NA"
            Cells(rw, "Y") = "NA"
            Cells(rw, "Z") = "NA"
            Cells(rw, "AA") = "NA"
            Cells(rw, "AB") = "NA"
            Cells(rw, "AD") = "NA"
            Cells(rw, "AL") = "NA"
            Cells(rw, "AM") = "NA"
            Cells(rw, "AN") = "NA"
            Cells(rw, "AP") = "NA"
            Cells(rw, "AQ") = "NA"
            Cells(rw, "AR") = "NA"
            Cells(rw, "AT") = "NA"
            Cells(rw, "AU") = "NA"

            Case "LocalSistemasVEEVA - Dispatch", "LocalSistemasVEEVA - Registration - Atualização", "LocalSistemasVEEVA - RO", "LocalElaboração_DossiêAvaliação de documentação", "LocalSistemasVeeva - Application"
            
                Cells(rw, "O") = "NA"
                Cells(rw, "R") = "NA"
                Cells(rw, "S") = "NA"
                Cells(rw, "U") = "NA"
                Cells(rw, "V") = "NA"
                Cells(rw, "W") = "NA"
                Cells(rw, "X") = "NA"
                Cells(rw, "Y") = "NA"
                Cells(rw, "Z") = "NA"
                Cells(rw, "AA") = "NA"
                Cells(rw, "AB") = "NA"
                Cells(rw, "AD") = "NA"
                Cells(rw, "AF") = "NA"
                Cells(rw, "AG") = "NA"
                Cells(rw, "AH") = "NA"
                Cells(rw, "AI") = "NA"
                Cells(rw, "AJ") = "NA"
                Cells(rw, "AK") = "NA"
                Cells(rw, "AL") = "NA"
                Cells(rw, "AM") = "NA"
                Cells(rw, "AN") = "NA"
                Cells(rw, "AP") = "NA"
                Cells(rw, "AQ") = "NA"
                Cells(rw, "AR") = "NA"
                Cells(rw, "AT") = "NA"
                Cells(rw, "AU") = "NA"
                
            Case "LocalSistemasVEEVA - Commitment", "LocalSistemasVEEVA - Correção", "LocalSistemasVEEVA - Bundling", "LocalSistemasVEEVA - HMP", "LocalSistemasVEEVA - Registration - Criação", "LocalSistemasVEEVA - Submission"
                Cells(rw, "J") = "NA"
                Cells(rw, "O") = "NA"
                Cells(rw, "R") = "NA"
                Cells(rw, "S") = "NA"
                Cells(rw, "U") = "NA"
                Cells(rw, "V") = "NA"
                Cells(rw, "W") = "NA"
                Cells(rw, "X") = "NA"
                Cells(rw, "Y") = "NA"
                Cells(rw, "Z") = "NA"
                Cells(rw, "AA") = "NA"
                Cells(rw, "AB") = "NA"
                Cells(rw, "AD") = "NA"
                Cells(rw, "AF") = "NA"
                Cells(rw, "AG") = "NA"
                Cells(rw, "AH") = "NA"
                Cells(rw, "AI") = "NA"
                Cells(rw, "AJ") = "NA"
                Cells(rw, "AK") = "NA"
                Cells(rw, "AL") = "NA"
                Cells(rw, "AM") = "NA"
                Cells(rw, "AN") = "NA"
                Cells(rw, "AP") = "NA"
                Cells(rw, "AQ") = "NA"
                Cells(rw, "AR") = "NA"
                Cells(rw, "AT") = "NA"
                Cells(rw, "AU") = "NA"
                               
                
              Case "LocalPeticionamentoFuncionamento da empresa (AE e AFE)", "LocalPeticionamentoGMP - Certificação inicial", "LocalPeticionamentoGMP - Renovação", "LocalPeticionamentoGMP - Inclusão de produto em linha já certificada", "LocalPeticionamentoGMP - Inclusão de produto em linha já certificada", "LocalPeticionamentoPós-registro", "LocalPeticionamentoRegistro", "LocalPeticionamentoRetificação de Publicação", "LocalPeticionamentoRotulagem - Demandas DRA - Alteração", "LocalPeticionamentoRotulagem - Pós Registro - Alteração", "LocalPeticionamentoRPF/RMP"
               
  
                Cells(rw, "U") = "NA"
                Cells(rw, "V") = "NA"
                Cells(rw, "W") = "NA"
                Cells(rw, "X") = "NA"
                Cells(rw, "Y") = "NA"
                Cells(rw, "AA") = "NA"
                Cells(rw, "AB") = "NA"
                Cells(rw, "AD") = "NA"
                Cells(rw, "AF") = "NA"
                Cells(rw, "AG") = "NA"
                Cells(rw, "AH") = "NA"
                Cells(rw, "AI") = "NA"
                Cells(rw, "AJ") = "NA"
                Cells(rw, "AK") = "NA"
                Cells(rw, "AL") = "NA"
                Cells(rw, "AM") = "NA"
                Cells(rw, "AN") = "NA"
                Cells(rw, "AP") = "NA"
                Cells(rw, "AQ") = "NA"
                Cells(rw, "AR") = "NA"
                Cells(rw, "AT") = "NA"
                Cells(rw, "AU") = "NA"
                
               Case "LocalElaboração_DossiêPós-registro - HMP - INFO SUP", "LocalElaboração_DossiêPós-registro - HMP - Paralelas", "LocalElaboração_DossiêPós-registro - HMP - Concomitante", "LocalElaboração_DossiêPós-registro - protocolo - INFO SUP"
               
                Cells(rw, "O") = "NA"
                Cells(rw, "R") = "NA"
                Cells(rw, "S") = "NA"
                Cells(rw, "T") = "NA"
                Cells(rw, "U") = "NA"
                Cells(rw, "V") = "NA"
                Cells(rw, "W") = "NA"
                Cells(rw, "X") = "NA"
                Cells(rw, "Y") = "NA"
                Cells(rw, "Z") = "NA"
                Cells(rw, "AA") = "NA"
                Cells(rw, "AB") = "NA"
                Cells(rw, "AD") = "NA"
                Cells(rw, "AL") = "NA"
                Cells(rw, "AM") = "NA"
                Cells(rw, "AN") = "NA"
                Cells(rw, "AP") = "NA"
                Cells(rw, "AQ") = "NA"
                Cells(rw, "AR") = "NA"
                Cells(rw, "AT") = "NA"
                Cells(rw, "AU") = "NA"
               
             Case "LocalPeticionamentoAditamento", "LocalPeticionamentoBula - Revisão de Bula Padrão", "LocalPeticionamentoCumprimento de Exigência", "LocalPeticionamentoDesistência a pedido", "LocalPeticionamentoHMP - Pós-registro - Mudança Exclusiva de HMP", "LocalPeticionamentoRecurso", "LocalPeticionamentoRotulagem - Demandas DRA - Notificação", "LocalPeticionamentoRotulagem - Pós Registro  - Notificação", "LocalPeticionamentoSolicitação de correção de dados na base", "LocalPeticionamentoToken", "LocalPeticionamentoTransferência de Titularidade"
               
                Cells(rw, "O") = "NA"
                Cells(rw, "U") = "NA"
                Cells(rw, "V") = "NA"
                Cells(rw, "W") = "NA"
                Cells(rw, "X") = "NA"
                Cells(rw, "Y") = "NA"
                Cells(rw, "Z") = "NA"
                Cells(rw, "AA") = "NA"
                Cells(rw, "AB") = "NA"
                Cells(rw, "AD") = "NA"
                Cells(rw, "AF") = "NA"
                Cells(rw, "AG") = "NA"
                Cells(rw, "AH") = "NA"
                Cells(rw, "AI") = "NA"
                Cells(rw, "AJ") = "NA"
                Cells(rw, "AK") = "NA"
                Cells(rw, "AL") = "NA"
                Cells(rw, "AM") = "NA"
                Cells(rw, "AN") = "NA"
                Cells(rw, "AP") = "NA"
                Cells(rw, "AQ") = "NA"
                Cells(rw, "AR") = "NA"
                Cells(rw, "AT") = "NA"
                Cells(rw, "AU") = "NA"
                               
            Case "LocalDesfechoPeticionamento - Renovação", "LocalDesfechoRenovação"
                Cells(rw, "O") = "NA"
                Cells(rw, "V") = "NA"
                Cells(rw, "W") = "NA"
                Cells(rw, "X") = "NA"
                Cells(rw, "Y") = "NA"
                Cells(rw, "AA") = "NA"
                Cells(rw, "AB") = "NA"
                Cells(rw, "AD") = "NA"
                Cells(rw, "AF") = "NA"
                Cells(rw, "AG") = "NA"
                Cells(rw, "AH") = "NA"
                Cells(rw, "AI") = "NA"
                Cells(rw, "AJ") = "NA"
                Cells(rw, "AK") = "NA"
                Cells(rw, "AL") = "NA"
                Cells(rw, "AM") = "NA"
                Cells(rw, "AN") = "NA"
                Cells(rw, "AP") = "NA"
                Cells(rw, "AQ") = "NA"
                Cells(rw, "AR") = "NA"
                Cells(rw, "AT") = "NA"
                Cells(rw, "AU") = "NA"

            Case "GlobalDesfechoCaixa Postal - Exigência", "GlobalDesfechoCaixa Postal - Ofício"
                Cells(rw, "J") = "NA"
                Cells(rw, "O") = "NA"
                Cells(rw, "R") = "NA"
                Cells(rw, "U") = "NA"
                Cells(rw, "V") = "NA"
                Cells(rw, "W") = "NA"
                Cells(rw, "X") = "NA"
                Cells(rw, "Y") = "NA"
                Cells(rw, "Z") = "NA"
                Cells(rw, "AA") = "NA"
                Cells(rw, "AB") = "NA"
                Cells(rw, "AD") = "NA"
                Cells(rw, "AF") = "NA"
                Cells(rw, "AG") = "NA"
                Cells(rw, "AH") = "NA"
                Cells(rw, "AI") = "NA"
                Cells(rw, "AJ") = "NA"
                Cells(rw, "AK") = "NA"
                Cells(rw, "AL") = "NA"
                Cells(rw, "AM") = "NA"
                Cells(rw, "AN") = "NA"
                Cells(rw, "AP") = "NA"
                Cells(rw, "AQ") = "NA"
                Cells(rw, "AR") = "NA"
                Cells(rw, "AT") = "NA"
                Cells(rw, "AU") = "NA"
                
            Case "GlobalDesfechoCBPF - Emissão Certificado", "GlobalDesfechoCBPF - Tradução de Certificado"
                Cells(rw, "J") = "NA"
                Cells(rw, "O") = "NA"
                Cells(rw, "R") = "NA"
                Cells(rw, "U") = "NA"
                Cells(rw, "V") = "NA"
                Cells(rw, "W") = "NA"
                Cells(rw, "Y") = "NA"
                Cells(rw, "Z") = "NA"
                Cells(rw, "AA") = "NA"
                Cells(rw, "AB") = "NA"
                Cells(rw, "AD") = "NA"
                Cells(rw, "AF") = "NA"
                Cells(rw, "AG") = "NA"
                Cells(rw, "AH") = "NA"
                Cells(rw, "AI") = "NA"
                Cells(rw, "AJ") = "NA"
                Cells(rw, "AK") = "NA"
                Cells(rw, "AL") = "NA"
                Cells(rw, "AM") = "NA"
                Cells(rw, "AN") = "NA"
                Cells(rw, "AP") = "NA"
                Cells(rw, "AQ") = "NA"
                Cells(rw, "AR") = "NA"
                Cells(rw, "AT") = "NA"
                Cells(rw, "AU") = "NA"
                                

             Case "LocalDOURevalidação automática", "LocalDOUAprovação condicional", "LocalDOUIndeferimento", "LocalDOUProrrogação do prazo de análise"
               
                Cells(rw, "O") = "NA"
                Cells(rw, "R") = "NA"
                Cells(rw, "V") = "NA"
                Cells(rw, "W") = "NA"
                Cells(rw, "X") = "NA"
                Cells(rw, "Y") = "NA"
                Cells(rw, "Z") = "NA"
                Cells(rw, "AA") = "NA"
                Cells(rw, "AB") = "NA"
                Cells(rw, "AD") = "NA"
                Cells(rw, "AF") = "NA"
                Cells(rw, "AG") = "NA"
                Cells(rw, "AH") = "NA"
                Cells(rw, "AI") = "NA"
                Cells(rw, "AJ") = "NA"
                Cells(rw, "AK") = "NA"
                Cells(rw, "AL") = "NA"
                Cells(rw, "AM") = "NA"
                Cells(rw, "AN") = "NA"
                Cells(rw, "AP") = "NA"
                Cells(rw, "AQ") = "NA"
                Cells(rw, "AR") = "NA"
                Cells(rw, "AT") = "NA"
                Cells(rw, "AU") = "NA"
                
             Case "LocalElaboração_DossiêBula - Pós Registro  - Notificação", "LocalElaboração_DossiêBula - Pós Registro - Alteração", "LocalElaboração_DossiêBula - CCDS/CCSI - Notificação"
             
                Cells(rw, "O") = "NA"
                Cells(rw, "R") = "NA"
                Cells(rw, "S") = "NA"
                Cells(rw, "U") = "NA"
                Cells(rw, "V") = "NA"
                Cells(rw, "W") = "NA"
                Cells(rw, "X") = "NA"
                Cells(rw, "Y") = "NA"
                Cells(rw, "Z") = "NA"
                Cells(rw, "AA") = "NA"
                Cells(rw, "AT") = "NA"
                Cells(rw, "AU") = "NA"
             Case "LocalElaboração_DossiêHMP", "LocalElaboração_DossiêAditamento"
               
                Cells(rw, "O") = "NA"
                Cells(rw, "R") = "NA"
                Cells(rw, "S") = "NA"
                Cells(rw, "U") = "NA"
                Cells(rw, "V") = "NA"
                Cells(rw, "W") = "NA"
                Cells(rw, "X") = "NA"
                Cells(rw, "Y") = "NA"
                Cells(rw, "Z") = "NA"
                Cells(rw, "AA") = "NA"
                Cells(rw, "AB") = "NA"
                Cells(rw, "AD") = "NA"
                Cells(rw, "AL") = "NA"
                Cells(rw, "AM") = "NA"
                Cells(rw, "AN") = "NA"
                Cells(rw, "AP") = "NA"
                Cells(rw, "AQ") = "NA"
                Cells(rw, "AR") = "NA"
                Cells(rw, "AT") = "NA"
                Cells(rw, "AU") = "NA"
                
                
            Case "LocalElaboração_DossiêRotulagem - Notificação", "LocalElaboração_DossiêRotulagem - Rotulário"
               
                Cells(rw, "O") = "NA"
                Cells(rw, "R") = "NA"
                Cells(rw, "S") = "NA"
                Cells(rw, "U") = "NA"
                Cells(rw, "V") = "NA"
                Cells(rw, "W") = "NA"
                Cells(rw, "X") = "NA"
                Cells(rw, "Y") = "NA"
                Cells(rw, "Z") = "NA"
                Cells(rw, "AA") = "NA"
                Cells(rw, "AB") = "NA"
                Cells(rw, "AD") = "NA"
                Cells(rw, "AL") = "NA"
                Cells(rw, "AT") = "NA"
                Cells(rw, "AU") = "NA"
                

                

                

             Case "LocalPeticionamentoCancelamento de Registro", "LocalPeticionamentoDescontinuação Temporária/ Definitiva"
               
                Cells(rw, "O") = "NA"
                Cells(rw, "U") = "NA"
                Cells(rw, "V") = "NA"
                Cells(rw, "W") = "NA"
                Cells(rw, "X") = "NA"
                Cells(rw, "Y") = "NA"
                Cells(rw, "AA") = "NA"
                Cells(rw, "AB") = "NA"
                Cells(rw, "AD") = "NA"
                Cells(rw, "AF") = "NA"
                Cells(rw, "AG") = "NA"
                Cells(rw, "AH") = "NA"
                Cells(rw, "AI") = "NA"
                Cells(rw, "AJ") = "NA"
                Cells(rw, "AK") = "NA"
                Cells(rw, "AL") = "NA"
                Cells(rw, "AM") = "NA"
                Cells(rw, "AN") = "NA"
                Cells(rw, "AP") = "NA"
                Cells(rw, "AQ") = "NA"
                Cells(rw, "AR") = "NA"
                Cells(rw, "AT") = "NA"
                Cells(rw, "AU") = "NA"
                


              Case "LocalRotulagem_ArtesVistalink", "LocalRotulagem_ArtesVistaVac"
               
                Cells(rw, "J") = "NA"
                Cells(rw, "O") = "NA"
                Cells(rw, "R") = "NA"
                Cells(rw, "T") = "NA"
                Cells(rw, "U") = "NA"
                Cells(rw, "W") = "NA"
                Cells(rw, "X") = "NA"
                Cells(rw, "Y") = "NA"
                Cells(rw, "AA") = "NA"
                Cells(rw, "AB") = "NA"
                Cells(rw, "AD") = "NA"
                Cells(rw, "AF") = "NA"
                Cells(rw, "AG") = "NA"
                Cells(rw, "AH") = "NA"
                Cells(rw, "AI") = "NA"
                Cells(rw, "AJ") = "NA"
                Cells(rw, "AK") = "NA"
                Cells(rw, "AL") = "NA"
                
              Case "LocalElaboração_DossiêPós-registro - HMP - Minor", "LocalElaboração_DossiêPós-registro - HMP - Simultâneas"
               
                Cells(rw, "O") = "NA"
                Cells(rw, "R") = "NA"
                Cells(rw, "S") = "NA"
                Cells(rw, "T") = "NA"
                Cells(rw, "U") = "NA"
                Cells(rw, "V") = "NA"
                Cells(rw, "W") = "NA"
                Cells(rw, "X") = "NA"
                Cells(rw, "AA") = "NA"
                Cells(rw, "AB") = "NA"
                Cells(rw, "AD") = "NA"
                Cells(rw, "AL") = "NA"
                Cells(rw, "AM") = "NA"
                Cells(rw, "AN") = "NA"
                Cells(rw, "AP") = "NA"
                Cells(rw, "AQ") = "NA"
                Cells(rw, "AR") = "NA"
                Cells(rw, "AT") = "NA"
                Cells(rw, "AU") = "NA"

              Case "GlobalDesfechoCBPF - DOU"
               
                Cells(rw, "O") = "NA"
                Cells(rw, "R") = "NA"
                Cells(rw, "U") = "NA"
                Cells(rw, "V") = "NA"
                Cells(rw, "W") = "NA"
                Cells(rw, "Y") = "NA"
                Cells(rw, "Z") = "NA"
                Cells(rw, "AA") = "NA"
                Cells(rw, "AB") = "NA"
                Cells(rw, "AD") = "NA"
                Cells(rw, "AL") = "NA"
                Cells(rw, "AF") = "NA"
                Cells(rw, "AG") = "NA"
                Cells(rw, "AH") = "NA"
                Cells(rw, "AI") = "NA"
                Cells(rw, "AJ") = "NA"
                Cells(rw, "AK") = "NA"
                Cells(rw, "AL") = "NA"
                Cells(rw, "AM") = "NA"
                Cells(rw, "AN") = "NA"
                Cells(rw, "AP") = "NA"
                Cells(rw, "AQ") = "NA"
                Cells(rw, "AR") = "NA"
                Cells(rw, "AT") = "NA"
                Cells(rw, "AU") = "NA"

              Case "LocalPeticionamentoRenovação de Produto"
               

                Cells(rw, "V") = "NA"
                Cells(rw, "W") = "NA"
                Cells(rw, "X") = "NA"
                Cells(rw, "Y") = "NA"
                Cells(rw, "AA") = "NA"
                Cells(rw, "AB") = "NA"
                Cells(rw, "AD") = "NA"
                Cells(rw, "AF") = "NA"
                Cells(rw, "AG") = "NA"
                Cells(rw, "AH") = "NA"
                Cells(rw, "AI") = "NA"
                Cells(rw, "AJ") = "NA"
                Cells(rw, "AK") = "NA"
                Cells(rw, "AL") = "NA"
                Cells(rw, "AM") = "NA"
                Cells(rw, "AN") = "NA"
                Cells(rw, "AP") = "NA"
                Cells(rw, "AQ") = "NA"
                Cells(rw, "AR") = "NA"
                Cells(rw, "AT") = "NA"
                Cells(rw, "AU") = "NA"
                
            Case "LocalPeticionamentoBula -CCDS / CCSI - Alteração"
            
                Cells(rw, "U") = "NA"
                Cells(rw, "X") = "NA"
                Cells(rw, "Y") = "NA"
                Cells(rw, "AB") = "NA"
                Cells(rw, "AD") = "NA"
                Cells(rw, "AF") = "NA"
                Cells(rw, "AG") = "NA"
                Cells(rw, "AH") = "NA"
                Cells(rw, "AI") = "NA"
                Cells(rw, "AJ") = "NA"
                Cells(rw, "AK") = "NA"
                Cells(rw, "AL") = "NA"
                Cells(rw, "AM") = "NA"
                Cells(rw, "AN") = "NA"
                Cells(rw, "AP") = "NA"
                Cells(rw, "AQ") = "NA"
                Cells(rw, "AR") = "NA"
                Cells(rw, "AT") = "NA"
                Cells(rw, "AU") = "NA"
                
             Case "LocalPeticionamentoBula - Pós Registro - Alteração"
            
                Cells(rw, "U") = "NA"
                Cells(rw, "V") = "NA"
                Cells(rw, "W") = "NA"
                Cells(rw, "X") = "NA"
                Cells(rw, "Y") = "NA"
                Cells(rw, "AA") = "NA"
                Cells(rw, "AB") = "NA"
                Cells(rw, "AD") = "NA"
                Cells(rw, "AF") = "NA"
                Cells(rw, "AG") = "NA"
                Cells(rw, "AH") = "NA"
                Cells(rw, "AI") = "NA"
                Cells(rw, "AJ") = "NA"
                Cells(rw, "AK") = "NA"
                Cells(rw, "AL") = "NA"
                Cells(rw, "AM") = "NA"
                Cells(rw, "AN") = "NA"
                Cells(rw, "AP") = "NA"
                Cells(rw, "AQ") = "NA"
                Cells(rw, "AR") = "NA"
                Cells(rw, "AT") = "NA"
                Cells(rw, "AU") = "NA"

            Case "LocalPeticionamentoReativação de Manufatura"

                Cells(rw, "O") = "NA"
                Cells(rw, "U") = "NA"
                Cells(rw, "V") = "NA"
                Cells(rw, "W") = "NA"
                Cells(rw, "X") = "NA"
                Cells(rw, "Y") = "NA"
                Cells(rw, "AA") = "NA"
                Cells(rw, "AB") = "NA"
                Cells(rw, "AD") = "NA"
                Cells(rw, "AF") = "NA"
                Cells(rw, "AG") = "NA"
                Cells(rw, "AH") = "NA"
                Cells(rw, "AI") = "NA"
                Cells(rw, "AJ") = "NA"
                Cells(rw, "AK") = "NA"
                Cells(rw, "AL") = "NA"
                Cells(rw, "AM") = "NA"
                Cells(rw, "AN") = "NA"
                Cells(rw, "AP") = "NA"
                Cells(rw, "AQ") = "NA"
                Cells(rw, "AR") = "NA"
                Cells(rw, "AT") = "NA"
                Cells(rw, "AU") = "NA"

             Case "LocalDOUDeferimento"

                Cells(rw, "O") = "NA"
                Cells(rw, "R") = "NA"
                Cells(rw, "V") = "NA"
                Cells(rw, "X") = "NA"
                Cells(rw, "Y") = "NA"
                Cells(rw, "AA") = "NA"
                Cells(rw, "AB") = "NA"
                Cells(rw, "AD") = "NA"
                Cells(rw, "AF") = "NA"
                Cells(rw, "AG") = "NA"
                Cells(rw, "AH") = "NA"
                Cells(rw, "AI") = "NA"
                Cells(rw, "AJ") = "NA"
                Cells(rw, "AK") = "NA"
                Cells(rw, "AL") = "NA"
                Cells(rw, "AM") = "NA"
                Cells(rw, "AN") = "NA"
                Cells(rw, "AP") = "NA"
                Cells(rw, "AQ") = "NA"
                Cells(rw, "AR") = "NA"
                Cells(rw, "AT") = "NA"
                Cells(rw, "AU") = "NA"
               
            Case "LocalPeticionamentoHMP"
            

                Cells(rw, "V") = "NA"
                Cells(rw, "W") = "NA"
                Cells(rw, "X") = "NA"
                Cells(rw, "Y") = "NA"
                Cells(rw, "Z") = "NA"
                Cells(rw, "AA") = "NA"
                Cells(rw, "AB") = "NA"
                Cells(rw, "AD") = "NA"
                Cells(rw, "AF") = "NA"
                Cells(rw, "AG") = "NA"
                Cells(rw, "AH") = "NA"
                Cells(rw, "AI") = "NA"
                Cells(rw, "AJ") = "NA"
                Cells(rw, "AK") = "NA"
                Cells(rw, "AL") = "NA"
                Cells(rw, "AM") = "NA"
                Cells(rw, "AN") = "NA"
                Cells(rw, "AP") = "NA"
                Cells(rw, "AQ") = "NA"
                Cells(rw, "AR") = "NA"
                Cells(rw, "AT") = "NA"
                Cells(rw, "AU") = "NA"
      
            Case "LocalOutrosEmissão de taxa - Registro/ Pós-registro"
            
                Cells(rw, "P") = "NA"
                Cells(rw, "Q") = "NA"
                Cells(rw, "S") = "NA"
                Cells(rw, "T") = "NA"
                Cells(rw, "U") = "NA"
                Cells(rw, "V") = "NA"
                Cells(rw, "W") = "NA"
                Cells(rw, "X") = "NA"
                Cells(rw, "Y") = "NA"
                Cells(rw, "Z") = "NA"
                Cells(rw, "AA") = "NA"
                Cells(rw, "AB") = "NA"
                Cells(rw, "AD") = "NA"
                Cells(rw, "AF") = "NA"
                Cells(rw, "AG") = "NA"
                Cells(rw, "AH") = "NA"
                Cells(rw, "AI") = "NA"
                Cells(rw, "AJ") = "NA"
                Cells(rw, "AK") = "NA"
                Cells(rw, "AL") = "NA"
                Cells(rw, "AM") = "NA"
                Cells(rw, "AN") = "NA"
                Cells(rw, "AP") = "NA"
                Cells(rw, "AQ") = "NA"
                Cells(rw, "AR") = "NA"
                Cells(rw, "AT") = "NA"
                Cells(rw, "AU") = "NA"
     
            Case "LocalDesfechoPeticionamento - HMP"
            
                Cells(rw, "O") = "NA"
                Cells(rw, "V") = "NA"
                Cells(rw, "W") = "NA"
                Cells(rw, "X") = "NA"
                Cells(rw, "Y") = "NA"
                Cells(rw, "Z") = "NA"
                Cells(rw, "AA") = "NA"
                Cells(rw, "AB") = "NA"
                Cells(rw, "AD") = "NA"
                Cells(rw, "AF") = "NA"
                Cells(rw, "AG") = "NA"
                Cells(rw, "AH") = "NA"
                Cells(rw, "AI") = "NA"
                Cells(rw, "AJ") = "NA"
                Cells(rw, "AK") = "NA"
                Cells(rw, "AL") = "NA"
                Cells(rw, "AM") = "NA"
                Cells(rw, "AN") = "NA"
                Cells(rw, "AP") = "NA"
                Cells(rw, "AQ") = "NA"
                Cells(rw, "AR") = "NA"
                Cells(rw, "AT") = "NA"
                Cells(rw, "AU") = "NA"
     
             Case "LocalDesfechoPeticionamento"
            
                Cells(rw, "O") = "NA"
                Cells(rw, "U") = "NA"
                Cells(rw, "V") = "NA"
                Cells(rw, "W") = "NA"
                Cells(rw, "X") = "NA"
                Cells(rw, "Y") = "NA"
                Cells(rw, "Z") = "NA"
                Cells(rw, "AA") = "NA"
                Cells(rw, "AB") = "NA"
                Cells(rw, "AD") = "NA"
                Cells(rw, "AF") = "NA"
                Cells(rw, "AG") = "NA"
                Cells(rw, "AH") = "NA"
                Cells(rw, "AI") = "NA"
                Cells(rw, "AJ") = "NA"
                Cells(rw, "AK") = "NA"
                Cells(rw, "AL") = "NA"
                Cells(rw, "AM") = "NA"
                Cells(rw, "AN") = "NA"
                Cells(rw, "AP") = "NA"
                Cells(rw, "AQ") = "NA"
                Cells(rw, "AR") = "NA"
                Cells(rw, "AT") = "NA"
                Cells(rw, "AU") = "NA"
            
           
            Case Else
'do nothing




        End Select
    Next cell
    
    Application.EnableEvents = True

End Sub

我目前有 35 个变量,但工作表太慢了。有人可以帮我吗?。谢谢!!

我的目标是根据下拉单元格和类型 NA(如果适用)搜索此组合

excel vba select case
1个回答
0
投票

也许更像这样:

Private Sub Worksheet_Change(ByVal Target As Range)
    Dim rng As Range, cell As Range, rw As Range
    
    Set rng = Intersect(Target, Me.Range("H:H"))
    If rng Is Nothing Then Exit Sub  'no updates in Col H?
    
    Application.EnableEvents = False

    'Loop through updated cells in column H
    For Each cell In rng.Cells
        Set rw = cell.EntireRow   'the whole row
        Select Case rw.Columns("I").Value 'check Col I on this row
            Case "LocalElaboração_DossiêCancelamento de Registro"
                'Here Range is relative to `rw`
                rw.Range("O1,R1:S1,U1:AB1,AD1,AL1:AN1,AP1:AR1,AT1:AU1").Value = "NA"
            'etc
            'etc
        End Select
    Next cell
    
    Application.EnableEvents = True

End Sub
© www.soinside.com 2019 - 2024. All rights reserved.