Reference Cell in Track Changes VBA

BigTenBoy15

New Member
Joined
Feb 24, 2016
Messages
9
I am using the below code to track changes in the "V&O Register" tab of a workbook I'm using. I would like the 8th value that it spits out (highlighted in red below) to be the value in column B of the same row that the initial change is being made in. The changes are being tracked in a separate tab called "Changes" so I'm not sure how to go back and reference the cell in a different tab. Please help!!!

Code:
Dim vOldValue
Dim User
Private Sub Worksheet_Change(ByVal Target As Range)
    Dim strAddress As String
    Dim val
    Dim dtmTime As Date
    Dim Rw As Long


    
    If Intersect(Target, Range("AuditRange")) Is Nothing Then Exit Sub
    
    dtmTime = Now()
    val = Target.Value
    strAddress = Target.Address
    
    Rw = Sheets("Changes").Range("A" & Rows.Count).End(xlUp).Row + 1
    With Sheets("Changes")
        .Cells(Rw, 1).Value = strAddress
        .Cells(Rw, 2).Value = val
        .Cells(Rw, 3).Formula = "=IFERROR(VLOOKUP(" & OnlyNums(strAddress) & ",VOIDReference, 2,FALSE),"""")"
        .Cells(Rw, 4).Value = dtmTime
        .Cells(Rw, 5).Value = vOldValue
        .Cells(Rw, 6).Value = User
        .Cells(Rw, 7).Formula = "=IFERROR(VLOOKUP(""" & User & """, UserNames, 2, FALSE), """")"
[COLOR=#ff0000]        .Cells(Rw, 8).Formula = "='V&O Register'!RC2"[/COLOR]
        
        


    End With
End Sub


Private Sub Worksheet_SelectionChange(ByVal Target As Range)


    vOldValue = Target
    User = Environ("UserName")
    


End Sub
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
Hi BigTenBoy15,

This should do the trick...

Code:
.Cells(Rw, 8).Value = Sheets("V&O Register").Range("B" & Target.Row).Value

Hope this helps,
Cheers,
Alan.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,923
Messages
6,122,283
Members
449,075
Latest member
staticfluids

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top