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

Poderiam me ajudar com isso?

Preciso de uma macro que atualize as datas da Coluna Data da tabela TB_ExpMatematica com um duplo clique em cada célula.

Segue planilha para aplicação e teste.
Você não está autorizado a ver ou baixar esse anexo.
#61479
Boa tarde, colegas.

Tentei resolver com a seguinte macro:
Código: Selecionar todos
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
    
    Dim Tabela As ListObject
    Dim Rng As Range
    
    Set Tabela = Wsh_EMi.ListObjects("TB_ExpMatematica")
    Set Rng = Tabela.ListColumns("Data").DataBodyRange
    
    If Target.Address <> Rng Then Exit Sub
        Target.Value = Date: Cancel = True
    
    Set Rng = Nothing
    Set Tabela = Nothing
        
End Sub
Porém não obtive êxito.

Alguém pode verificar?

Segue planilha com a macro.
Você não está autorizado a ver ou baixar esse anexo.
#61656
Fiz uma pequena alteração aqui para apontar o range da coluna data e deu certo.
Código: Selecionar todos
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    
    Dim Plan As Worksheet
    Dim Tabela As ListObject
    Dim Col_Data As Range
    
    Set Plan = Wsh_EMi
    Set Tabela = Plan.ListObjects("TB_ExpMatematica")
    Set Col_Data = Tabela.ListColumns("Data").DataBodyRange
    
    Application.ScreenUpdating = False

    If Not Intersect(Target, Col_Data) Is Nothing Then
    
        Cancel = True
        ActiveCell = Date
        ActiveCell.Offset(0, 0).Select
    
    End If
    
    Application.ScreenUpdating = True

End Sub
Muito obrigado.
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