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 davispi
Posts
#41280
Boa noite,
Preciso excluir da planilha em anexo as linhas que contiverem os valores " - " das células D e J e jogar o conteúdo ( se existir) para a cima (como o próprio Excel faz) confesso que sou leigo no assunto, achei essa macro que supostamente faz o que eu preciso, porém chega a um determinado valor ela da Erro e para, se alguém puder me ajudar agradeço.

Sub limpar_relatorio()

' Excluir Inativos
Application.ScreenUpdating = False
Range("D:J").Select
Dim w As Range
Dim faixa As Range

Set faixa = Selection
Dim criterio As String
criterio = "-"
For Each w In faixa
If InStr(1, w.Value2, criterio) <> 0 Then
w.Activate
ActiveCell.EntireRow.Delete
Call Excluir_Inativos
Exit Sub
End If
Next

Application.ScreenUpdating = True
End Sub
Você não está autorizado a ver ou baixar esse anexo.
Por osvaldomp
#41299
Experimente:
Código: Selecionar todos
Sub ExcluiLinhas()
 Application.ScreenUpdating = False
  Range("K11:K" & Cells(Rows.Count, 2).End(3).Row).Value = "=IF(D11=""-"",1,0)"
  Range("A11:K" & Cells(Rows.Count, 2).End(3).Row).AutoFilter 11, 1
  Range("A12:K" & Cells(Rows.Count, 2).End(3).Row).EntireRow.Delete
  ActiveSheet.AutoFilterMode = False
  Columns(11).Value = ""
 Application.ScreenUpdating = True
End Sub
Por davispi
Posts
#41311
Boa Tarde, Primeiramente obrigado, a macro funcionou em parte ela removeu tudo da certinho da coluna D porém da coluna J que tb tem "-" ela não removeu
Por osvaldomp
#41314
Verdade. Falha minha. Desculpe.

substitua esta expressão no código
"=IF(D11=""-"",1,0)"

por esta
"=IF(OR(D11=""-"",J11=""-""),1,0)"
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