Track changes to single cells

sharky12345

Well-known Member
Joined
Aug 5, 2010
Messages
3,421
Office Version
  1. 2016
Platform
  1. Windows
I have this which I am using to track changes to a range;

Code:
    Dim xrng As Range    Set xrng = Range("A2:N16")
    If Not Application.Intersect(xrng, Range(Target.Address)) _
       Is Nothing Then
        Set ws = Sheet1
        iRow = ws.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
        ws.Cells(iRow, 1).Value = ActiveSheet.Name
        ws.Cells(iRow, 2).Value = Target.Address(False, False)
    End If

It works great, tracking the cell value and storing it for use later, but if I selected multiple cells and edit them at once it stores the cell value as 'E11:E15', (as an example), which means I can't use it later because it's not a single cell value.

Can anyone suggest a workaround or tweak so that it stores the value of every cell changed as a separate line?
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
Try this. Also ws is undeclared. I strongly recommend to everyone that they declare variables. Doing so prevents a lot of bugs and runtime errors.

Code:
    Dim xrng As Range
    Dim Cell As Range
    Dim ws As Worksheet
    
    Set xrng = Range("A2:N16")
    
    For Each Cell In Target
      If Not Application.Intersect(xrng, Cell) Is Nothing Then
          Set ws = Sheet1
          iRow = ws.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
          ws.Cells(iRow, 1).Value = ActiveSheet.Name
          ws.Cells(iRow, 2).Value = Cell.Address(RowAbsolute:=False, ColumnAbsolute:=False)
      End If
    Next Cell
 
Upvote 0

Forum statistics

Threads
1,223,214
Messages
6,170,771
Members
452,353
Latest member
strainu

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