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

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
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,215,438
Messages
6,124,873
Members
449,192
Latest member
MoonDancer

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