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
#73227
Boa tarde, pessoal.

Poderiam me ajudar com uma Macro que compara a Tabela TB_Bovespa_Operacoes com a Tabela TB_Bovespa_Carteira_de_Ativos?

Preciso que a Macro Exclua as linhas da Tabela TB_Bovespa_Carteira_de_Ativos (Tabela de Cor Verde) em que o Valor da Coluna Registro seja igual ao Valor da Coluna Registro da tabela TB_Bovespa_Operacoes (Tabela de Cor Azul) em que a Coluna [Bovespa (Carteira de Ativos)] seja igual a "" (Vazio).

No caso do exemplo anexo o resultado deve excluir as linhas de registro iguais a 3, 6 e 7.
Coloquei resultado esperado na Tabela TB_Resultado_Desejado (Tabela de Cor Laranja).

Segue planilha para verificação.
Você não está autorizado a ver ou baixar esse anexo.
#73228
Bom dia.
Segue uma opção.
Até
Foxtri
Sub Excluir()
Dim Ulin As Long, XRng As Range, Cel As Range, XArea As Range
With Sheets("BOVESPA (OPERAÇÕES)")
Ulin = .Cells(Rows.Count, "B").End(xlUp).Row
Set XRng = .Range(.Cells(ActiveSheet.ListObjects(1).ListColumns("Registro").DataBodyRange(1, 1).Row, "H"), .Cells(Ulin, "H"))
For Each Cel In XRng
If Trim(Cel) = vbNullString Then
Set XArea = Sheets("BOVESPA (CARTEIRA DE ATIVOS)").Range("TB_Bovespa_Carteira_de_Ativos[Registro]").Find(Sheets("BOVESPA (OPERAÇÕES)").Cells(Cel.Row, 2))
If Not XArea Is Nothing Then
With Sheets("BOVESPA (CARTEIRA DE ATIVOS)")
.Range(.Cells(XArea.Row, "B"), .Cells(XArea.Row, "I")).Delete
End With
End If
End If
Next Cel
End With
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