Macro to link selected cell to most recently edited cell.

Jaegan

New Member
Joined
Mar 19, 2012
Messages
3
Hey folks. Looking to make a very basic macro, but my VBA skills are below basic!

Essentially, I want a macro that when used will set the currently selected cell to reference to the cell I most recently edited. So for example, after I complete the sum in C9, I want to go to cell A1, run my macro, and have A1 generate the formula linking it to cell C9.

=C9
5
4
=SUM(C1:C3)

<tbody>
</tbody>


The main challenge I think will be trying to get the references to work across tabs (e.g. adding in the !sheet references when needed). Any pointers you can provide would be much appreciated!
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
In every worksheet, include the follow event macro in the worksheet code area:

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    LastChanged = "=" & Target.Parent.Name & "!" & Target.Address
End Sub
In a standard module include the following:

Code:
Public LastChanged As String
Sub CaptureLastChanged()
    Application.EnableEvents = False
        ActiveCell.Formula = LastChanged
    Application.EnableEvents = True
End Sub

So after you have done some edits, run CaptureLastChanged to settup the activecell
 
Upvote 0
Thanks a bunch. I will fiddle with this a bit later today and let you know if I run into any issues.

It sounds like there is no way around having to include the macro event in each tab if I want this to work. Would I be correct that even if we were to limit the macro functionality to only link to a cell within a specific tab ( no cross tab linking), we would still need the event macro in order to flag the most recently edited cell?
 
Upvote 0
The event macro needs to be included only in those tabs in which you wish to capture the last cell edited.
 
Upvote 0

Forum statistics

Threads
1,215,436
Messages
6,124,869
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