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.
  • Avatar do usuário
Por BrunoLuiel
Posts
#59863
Bom dia Amigos! Estou tentando fazer um PROCV pelo VBA mas encontro dificuldades, o caso é o seguinte

tenho 3 worksheets:

Vendas (é onde tem o valor procurado no PROCV)
Lançamentos (onde será lançado o PROCV)
Base (matriz tabela para PROCV)

Devido a uma outra estrutura junto a esta que tenho problemas, eu precisava que o valor procurado fosse uma variável e a Base matriz fosse fixa...

Segue a planilha em anexo.

Para explicar melhor o que preciso eu tentei isso...

Sub Lançamentos ()

Do Until Sheets("vendas").Cells(Lin, 1) = ""

Lin = 2 'Linha
Sheets("Base de Dados").Columns("A:B").Name = "CAa" 'Matriz tabela

Sheets("Lançamentos").Range("B" & Lin) = worksheetfunction.VLookup(Range("vendas!B"&Lin, CAa, 2, 0)

Lin = Lin + 1

Loop

End sub
Você não está autorizado a ver ou baixar esse anexo.
Avatar do usuário
Por AfonsoMira
Posts Avatar
#59866
Veja se é isso que pretende.
Código: Selecionar todos
Sub Lançamentos()

'Matriz Tabela
matriz = Sheets("base de Dados").Range("A:B")

linha = 2

Do Until Sheets("vendas").Cells(linha, 1) = ""

valorProcurar = Sheets("vendas").Cells(linha, 2).Value

On Error Resume Next
resultadoProcV = WorksheetFunction.VLookup(valorProcurar, matriz, 2, False)
On Error GoTo 0

Sheets("Lançamentos").Cells(linha, 1).Value = valorProcurar
Sheets("Lançamentos").Cells(linha, 2).Value = resultadoProcV

linha = linha + 1

Loop

End Sub
BrunoLuiel, Kledison agradeceu por isso
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