Este fórum está sendo desativado

Depois de 9 anos, este fórum será desativado. Mas calma.... estamos migrando para uma comunidade no DISCORD. Junte-se a nós.

ENTRAR PARA DISCORD

Tópicos relacionados a códigos VBA, gravação de macros, etc.
Por vjpm18
#45659
Boa tarde a todos!

Poderia me ajudar a como fazer umas busca que atenda 2 intervalos de valores ?

Tenho uma tabela de x e y e seus respectivos valores, preciso de um valor que atenda 2 INTERVALOS distintos (Menor ou igual ; Maior ou igual) .

Como posso fazer isso ?

Desde já,
Muito obrigado!
Você não está autorizado a ver ou baixar esse anexo.
Por eduardogrigull
Posts
#46096
Olá, resolvi o problema com um Script. É só colocar num módulo VBA e chamar através de algum botão.
Código: Selecionar todos
Dim UltimoRegistro As Integer
Sub Pesquisa()

'Verificar se foi digitado algo pra pesquisa
If Cells.Range("G3").Value = Empty Or Cells.Range("G4").Value = Empty _
    Or Cells.Range("J3").Value = Empty Or Cells.Range("J4").Value = Empty Then
    MsgBox "Digite algo"
    Exit Sub
End If

'Achar o ultimo registro
UltimoRegistro = Range("A2").End(xlDown).Row

'Fazer um loop e procurar
For i = 1 To UltimoRegistro
    
    'Variavel A
    If Cells(i, 3).Value <= Cells.Range("G3").Value And Cells(i, 3).Value >= Cells.Range("G4").Value Then
        
        'Variavel B
        If Cells(i, 4).Value <= Cells.Range("J3").Value And Cells(i, 4).Value >= Cells.Range("J4").Value Then
            
            'Resultado encontrado
            Cells.Range("H9").Value = Cells(i, 1).Value
            Cells.Range("H11").Value = Cells(i, 2).Value
            Exit Sub
        End If
    End If
Next

'Nada encontrado
MsgBox "Nenhum resultado encontrado"

End Sub
long long title how many chars? lets see 123 ok more? yes 60

We have created lots of YouTube videos just so you can achieve [...]

Another post test yes yes yes or no, maybe ni? :-/

The best flat phpBB theme around. Period. Fine craftmanship and [...]

Do you need a super MOD? Well here it is. chew on this

All you need is right here. Content tag, SEO, listing, Pizza and spaghetti [...]

Lasagna on me this time ok? I got plenty of cash

this should be fantastic. but what about links,images, bbcodes etc etc? [...]

Estamos migrando para uma comunidade no Discord