Bloco if sem end

Carla - 24 dez 2022 às 06:39

Bom dia, 

podiam-me ajudar sempre que efetuo este  código vba ele diz-me bloco if sem end if, sou novata em vba e não consigo  descobrir onde está o  problema..  

Private Sub Textpesquisa_Change()


valor_pesq = Textpesquisa.Text

    If shtAgenda.Range("OpcaoPesquisa") = 1 Then
    Coluna = 2

    ElseIf shtAgenda.Range("OpcaoPesquisa") = 2 Then
    Coluna = 4
    Else
    Coluna = 5
    End If

    LinhaListbox = 0
    Conta_registros = 0
    Linha = 2
    
    shtAgenda.ListBoxPesquisa.Clear
    
  If shtAgenda.Range("OpcaoPesquisa") = 1 Then
Coluna = 2

    
    With shtBase
        While .Cells(Linha, Coluna).Value <> Empty
            Valor_celula = .Cells(Linha, Coluna).Value
            
            If UCase(Left(Valor_celula, Len(valor_pesq))) = UCase(valor_pesq) Then
            
        With shtAgenda.ListBoxPesquisa
        
    .AddItem
    .List(LinhaListbox, 0) = shtBase.Cells(Linha, 1) 'Codigo
    .List(LinhaListbox, 1) = shtBase.Cells(Linha, 2) 'Nome
    .List(LinhaListbox, 2) = shtBase.Cells(Linha, 5) 'Extensao
    .List(LinhaListbox, 3) = shtBase.Cells(Linha, 6) 'Telefone
    End With
    Conta_registros = Conta_registros + 1
    
    End If
    
    Linha = Linha + 1
    Wend
End With
    shtAgenda.Range("NRegistros") = Conta_registros
   
End Sub

Windows / Chrome 108.0.0.0

Assine nossa newsletter!

Assine nossa newsletter!
Junte-se à comunidade