ExcelGiu21
New Member
- Joined
- Jul 8, 2021
- Messages
- 1
- Office Version
- 365
- 2019
- Platform
- Windows
Hello, I am using an online translator.
I have in VBA "EVENTLog"
I have a Table that goes from A to G
A = Author
B = Sheet Name
C = Line
D = Entered value
E = Old Value
F = current value
G = Date / Time
the information comes from the sheet "sheet1"
In "Sheet1" I wrote "Name" in D2
the VBA returns Cell C2 and D2 in the "Eventlog" sheet
how to return C1 and D2, or, F1 and G2 or, if I write in D3 returns C1 and D3?
Could you help me?
this is my VBA CODE :
thx.
I have in VBA "EVENTLog"
I have a Table that goes from A to G
A = Author
B = Sheet Name
C = Line
D = Entered value
E = Old Value
F = current value
G = Date / Time
the information comes from the sheet "sheet1"
In "Sheet1" I wrote "Name" in D2
the VBA returns Cell C2 and D2 in the "Eventlog" sheet
how to return C1 and D2, or, F1 and G2 or, if I write in D3 returns C1 and D3?
Could you help me?
this is my VBA CODE :
VBA Code:
Private Sub Workbook_SheetChange (ByVal sheet As Object, ByVal target As Range)
Dim before () As Variant, after () As Variant
On Error GoTo end:
If sheet.Name = "Journal" Then Exit Sub
If target.Columns.Count = Columns.Count Or target.Rows.Count = Rows.Count Then
Application.EnableEvents = False
Application.Undo
Application.EnableEvents = True
MsgBox "Cannot act on a full row or column!"
Exit Sub
End If
Application.EnableEvents = False
ReDim before (1 TB target.Rows.Count, 1 TB target.Columns.Count)
ReDim after (1 TB target.Rows.Count, 1 TB target.Columns.Count)
Application.Undo
For Lig = 1 To UBound (before)
For col = 1 To UBound (before, 2)
before (Lig, col) = target.Cells (1, 1) .Offset (Lig - 1, col - 1) .FormulaLocal
Next
Next
Application.Undo
For Lig = 1 To UBound (after)
For col = 1 To UBound (after, 2)
after (Lig, col) = target.Cells (1, 1) .Offset (Lig - 1, col - 1) .FormulaLocal
Next
Next
For Lig = 1 TB target.Rows.Count
For col = 1 TB target.Columns.Count
If before (Lig, col) <> after (Lig, col) Then
With Sheets ("Journal"). ListObjects (1)
.ListRows.Add
i = .ListRows.Count
With .DataBodyRange
.Cells (i, 7) = Now
.Cells (i, 2) = sheet.Name
.Cells (i, 4) = target.Cells (1, 1) .Offset (Lig - 1, col - 1)
.Cells (i, 3) = target.Cells (1, 1) .Offset (Lig - 1, premierecol - 1)
.Cells (i, 5) = "" & before (Lig, col)
.Cells (i, 6) = "" & after (Lig, col)
.Cells (i, 1) = Environ ("username")
End With
End With
End If
Next
Next
end:
Application.EnableEvents = True
If Err Then MsgBox "Error #" & Err.Number & "!"
End Sub
thx.
Last edited by a moderator: