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 SandroLima
#40182
Bom dia, pessoal

Podem verificar pq o código da planilha "Atividades Diarias" não está funcionando?
Código: Selecionar todos
Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)
    
    Dim TabelaConsulta As ListObject, TabelaConsulta2 As ListObject
        
    Set TabelaConsulta = wshAtivDiarias.ListObjects("TB_ConsultaAtivCadastrada")
    Set TabelaConsulta2 = wshPlanAuxiliar.ListObjects("TB_ConsultaAtivCadastrada2")
    
    If Not Application.Intersect(Target, TabelaConsulta.ListColumns("Data").DataBodyRange) Is Nothing And VBA.IsDate(Target.Value) Then
        With wshPlanAuxiliar
            .Range("Ano_Referencia").Value2 = VBA.Year(Target.Value2)
            .Range("Mes_Referencia").Value2 = Application.WorksheetFunction.Proper(VBA.Format(Target.Value2, "mmmm"))
        End With
    End If
    
    If Not Application.Intersect(Target, TabelaConsulta.ListColumns("Fluxo").DataBodyRange) Is Nothing Then
        With TabelaConsulta2.ListRows(1)
            .Range(1, 5).Value2 = TabelaConsulta.ListRows(1).Range(1, 5).Value2 'Coluna Fluxo
        End With
    End If
    
    If Not Application.Intersect(Target, TabelaConsulta.ListColumns("Periodicidade").DataBodyRange) Is Nothing Then
        With TabelaConsulta2.ListRows(1)
            .Range(1, 6).Value2 = TabelaConsulta.ListRows(1).Range(1, 6).Value2 'Coluna Periodicidade
        End With
    End If
    
End Sub
A cada alteração nos campos relacionados do código da planilha "Atividades Diarias" ele deveria alterar o respectivo campo da "Plan_Aux".

Há como o código ser melhorado/resumido. Fiz ele baseado apenas no campo data e depois incluí os demais campos (Fluxo e Periodicidade)

Obrigado a quem puder colaborar.
Você não está autorizado a ver ou baixar esse anexo.
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