PDA

View Full Version : Select Previously Edited Cell



Jarlisle
01-29-2010, 05:31 PM
I need to create a macro that will be able to move data from a previously entered cell to a different sheet. I'm running into a problem with the first part of it.

If I enter data into cell B5 and either press enter, click into another cell, press tab or any other way of moving cells I need the macro to somehow record B5 and then I can reference that in another macro to copy and paste it elsewhere. I assume this code will have to go into the Private Sub using "Worksheet_SelectionChange" and then I can use another macro to execute a copy and paste when I want it to. I just don't know if it's possible to reference a previosly entered cell.

The other challenge I have is that I want the copy and paste to only trigger on certain cells. Meaning if I enter data in any cell in B5:Z5 then I want to take that data and enter it into another sheet.

xld
01-29-2010, 05:35 PM
First part, save the value in a module scope variable, and use that later.

To just work in B5:Z5, test that range a like so



If Not Intersect (Target, Me.Range("B5:Z5")) Is Nothing Then

'do stuff
End If

mikerickson
01-31-2010, 01:58 AM
I'd look at the Worksheet_Change event rather than SelectionChange.