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
#69027
Como faço para executar um bloco de comando se a tecla enter for pressionada no evento change da worksheet?

Neste exemplo:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Row > 2 and "tecla enter pressionada" Then
ActiveSheet.Range("$A$2:$F$" & UltimaLinha).AutoFilter Field:=3
ActiveSheet.Range("$A$2:$F$67").AutoFilter Field:=3, Criteria1:="=a", _
Operator:=xlOr, Criteria2:="=p"
Application.EnableEvents = True
ActiveWorkbook.Save
End If
end sub
#69029
Não tem o evento Enter No worksheet, mas pode-se capturar a tecla Enter com a função Onkey
colocando o metodo na abertura da pasta de trabalho, para ao digitar Enter, chama sua macro
Código: Selecionar todos
  Sub Auto_open()

Excel.Application.OnKey "{ENTER}", "Sua_Macro"
 
End Sub
... sua macro ....
Código: Selecionar todos
Sub Sua_Macro()
If Not Excel.Application.Intersect(Selection, Range("A1:Z1")) Is Nothing Then
   If ActiveCell.Row > 2 Then
    ActiveSheet.Range("$A$2:$F$" & UltimaLinha).AutoFilter Field:=3
    ActiveSheet.Range("$A$2:$F$67").AutoFilter Field:=3, Criteria1:="=a", _
    Operator:=xlOr, Criteria2:="=p"
    Application.EnableEvents = True
    ActiveWorkbook.Save
   End If
End If
End Sub
JapSmart 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