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 gabrielc
#11830
Bom dia, pessoal! Tinha criado este tópico (http://gurudoexcel.com/forum/viewtopic.php?f=7&t=2272) para uma ajuda ... porém já resolvi colocando um VBA:
Código: Selecionar todos
Private Sub Worksheet_Change(ByVal Target As Range)
'Update 20140722
Dim WorkRng As Range
Dim Rng As Range
Dim xOffsetColumn As Integer
Set WorkRng = Intersect(Application.ActiveSheet.Range("B:B"), Target)
xOffsetColumn = 1
If Not WorkRng Is Nothing Then
    Application.EnableEvents = False
    For Each Rng In WorkRng
        If Not VBA.IsEmpty(Rng.Value) Then
            Rng.Offset(0, xOffsetColumn).Value = Now
            Rng.Offset(0, xOffsetColumn).NumberFormat = "dd-mm-yyyy, hh:mm:ss"
        Else
            Rng.Offset(0, xOffsetColumn).ClearContents
        End If
    Next
    Application.EnableEvents = True
End If
End Sub
Agora, eu preciso que toda a modificação que eu fizer, além de atualizar a data de modificação, preciso que salve em outra folha... por exemplo: Retirei 5 canetas da célula B5 no dia 15/06/2016, na célula C5, atualizou esta data e na outra folha, na célula A5, salvou a data. Dai a mesma coisa, no dia 16/05/2016, retirei 3 canetas dai na outra folha na célula A6, salvou também...
Alguem consegue dar esse help?
Avatar do usuário
Por alexandrevba
Avatar
#11832
Bom dia!!

dessa vez, por favor, click na mãozinha!!
Código: Selecionar todos
Private Sub Worksheet_Change(ByVal Target As Range)
'Update 20140722
Dim WorkRng As Range
Dim Rng As Range
Dim xOffsetColumn As Integer
Dim lngLastRow As Long
    lngLastRow = Sheets("Plan2").Range("A" & Rows.Count).End(xlUp).Row

Set WorkRng = Intersect(Application.ActiveSheet.Range("B:B"), Target)
xOffsetColumn = 1
If Not WorkRng Is Nothing Then
    Application.EnableEvents = False
    For Each Rng In WorkRng
        If Not VBA.IsEmpty(Rng.Value) Then
            Rng.Offset(0, xOffsetColumn).Value = Now
            Rng.Offset(0, xOffsetColumn).NumberFormat = "dd-mm-yyyy, hh:mm:ss"
            'Tente algo assim....
            ActiveCell.Offset(-1, 0).Copy Destination:=Worksheets("Plan2").Cells(Cells.Rows.Count, 1).End(xlUp).Offset(1, 0)
        Else
            Rng.Offset(0, xOffsetColumn).ClearContents
        End If
    Next
    Application.EnableEvents = True
End If
End Sub
Att
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