Stuck, find the last changed cell and use that cell in my macro.

Luke1690

Board Regular
Joined
Jul 26, 2022
Messages
121
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Hi,

i have a workbook full of data, columns A2,I2

Colleagues go into the workbook find the row they need and edit it, in no particular order. When they edit the row i have a formula using (Concatenate) that creates a filename for them to use in column I.

I'm using a macro that creates this folder and sub folders this is all done so the names are consistent.

The trouble I'm having is, I have to use the code multiple times on every row to pick the correct file name.

i cant use last row either as the sheet is filled in randomly.

is there away to find last changed cell then have it show in (L1) so i can use the below



strName = (Sheets("sheet1").Range("l1").Value)


i cant share the sheet ill have to mock something up if needs be.

Thanks guys
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
This code will run whenever a change is made in the specified worksheet, updating the lastChangedCell variable accordingly. You can modify this code to suit your specific requirements, such as logging the change in a separate location or performing additional actions based on the change.

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    ' Static variable to hold the address of the last changed cell
    Static lastChangedCell As String
    
    ' Update the address of the last changed cell
    lastChangedCell = Target.Address
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,912
Messages
6,175,341
Members
452,638
Latest member
Oluwabukunmi

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