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 Adrian
Posts
#6816
Parceiros tenho na Coluna "A" os meses abaixo:
e na "B" Ano e na "C" também exemplo:
MÊS | 2015 | 2016
JAN 2000 200
FEV
MAR
ABR
MAI
JUN
JUL
AGO
SET
OUT
NOV
DEZ
Preciso de uma macro que filtre sempre o Mês atual, nesse caso JAN. Assim que clicar no botão que eu atribui a macro ele me filtre aquele mês que estamos. Tem como?

Grato

Adrian
Avatar do usuário
Por Reinaldo
Avatar
#6824
Na falta de maiores informações, tente adaptar a sua realidade
Código: Selecionar todos
Private Sub ComboBox1_Change()
Dim Dtini As Date, DtFim As Date, Mes As Integer

If ComboBox1.Text <> "" And ComboBox1.Text <> "Pesquisar !!!!" Then
    Dtini = CDate(1 & "/" & ComboBox1.Text & "/" & Year(Date))
    DtFim = Application.WorksheetFunction.EoMonth(Dtini, 0)
Else
    'ActiveSheet.ShowAllData
    Exit Sub
End If

  If IsDate(Dtini) And IsDate(DtFim) Then
    Selection.AutoFilter Field:=1, _
    Criteria1:=">=" & Format(Dtini, "mm/dd/yyyy"), Operator:=xlAnd, _
    Criteria2:="<=" & Format(DtFim, "mm/dd/yyyy")
  Else
    ActiveSheet.ShowAllData
  End If
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