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 welemes
#17948
Olá,

Continuo batendo cabeça em uma coisa simples.
O que eu gostaria de fazer é o seguinte:
Em um cabeçalho de três colunas aplicar um filtro
Na coluna C
Baseado no texto da primeira célula ativa (Abaixo do cabeçalho), o excel trazer vai subir uma MsgBox.
Exemplo
Tenho as seguintes coluna
Nome / Valor/ Situação
' Aplicando o filtro na situação, vai constar "Ok" ou "Deve"
Se quando eu aplicar o filtro, deixando só a palavra "Deve", sobe uma MsgBox "Deve muito"
Só reforçando, se o valor da primeira célula ativa (abaixo do cabeçalho) for "Deve", subir a MsgBox

Estou usando o seguinte código:

Sub teste()

Dim teste1 As String

teste1 = Range("C4", Cells(Rows.Count, "C").End(xlUp)).SpecialCells(xlCellTypeVisible).Cells(1, 1).Select

If teste1 = "OK" Then
MsgBox "Pago"
End If

If teste1 = "Deve" Then
MsgBox "Deve"

End If

End Sub
Avatar do usuário
Por alexandrevba
Avatar
#17975
Bom dia!!

Tente assim, veja se funciona.
Código: Selecionar todos
Sub teste()

Dim teste1 As String

teste1 = Range("C2", Cells(Rows.Count, "C").End(xlUp)).SpecialCells(xlCellTypeVisible).Cells(1, 1).Select

If ActiveCell = "OK" Then
    MsgBox "Pago"
End If

If ActiveCell = "Deve" Then
    MsgBox "Deve"
End If

End Sub
At
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