ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Last ActiveCell (https://www.excelbanter.com/excel-programming/416815-last-activecell.html)

steven

Last ActiveCell
 
When you change cells is there a way to tell which was the last active cell.

Thank you,

Steven

Bob Phillips[_3_]

Last ActiveCell
 
Ctrl-Z will take you back there.

--
__________________________________
HTH

Bob

"Steven" wrote in message
...
When you change cells is there a way to tell which was the last active
cell.

Thank you,

Steven




FSt1

Last ActiveCell
 
hi
excel doesn't remember last cells but you can do it with variables.
dim r as range
range("A1").select
set r = activecell
range("B9").select 'A1 was last activecell
set r = activecell 'now B9 is last activecell.

you can set varaibles for last sheet also so as to return to a point(sheet
and cell) after going off to do other stuff.

regards
FSt1

regards
FSt1


"Steven" wrote:

When you change cells is there a way to tell which was the last active cell.

Thank you,

Steven


Kent Prokopy

Last ActiveCell
 
Put this in the ThisWorkBook module:

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
Dim LastCell As String
LastCell = Cells(Target.Row, Target.Column).Address
End Sub



"Steven" wrote:

When you change cells is there a way to tell which was the last active cell.

Thank you,

Steven


Otto Moehrbach[_2_]

Last ActiveCell
 
Bob
Is there some reference that has to be active for this Ctrl-Z to work?
I have 2002 and Ctrl-Z doesn't do anything for me. Thanks for your time.
Otto
"Bob Phillips" wrote in message
...
Ctrl-Z will take you back there.

--
__________________________________
HTH

Bob

"Steven" wrote in message
...
When you change cells is there a way to tell which was the last active
cell.

Thank you,

Steven





Otto Moehrbach[_2_]

Last ActiveCell
 
Kent
What does do this do toward finding the previous cell? Otto
"Kent Prokopy" wrote in message
...
Put this in the ThisWorkBook module:

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As
Range)
Dim LastCell As String
LastCell = Cells(Target.Row, Target.Column).Address
End Sub



"Steven" wrote:

When you change cells is there a way to tell which was the last active
cell.

Thank you,

Steven



Jim Rech

Last ActiveCell
 
Ctrl-z is Undo.

--
Jim
"Otto Moehrbach" wrote in message
...
| Bob
| Is there some reference that has to be active for this Ctrl-Z to work?
| I have 2002 and Ctrl-Z doesn't do anything for me. Thanks for your time.
| Otto
| "Bob Phillips" wrote in message
| ...
| Ctrl-Z will take you back there.
|
| --
| __________________________________
| HTH
|
| Bob
|
| "Steven" wrote in message
| ...
| When you change cells is there a way to tell which was the last active
| cell.
|
| Thank you,
|
| Steven
|
|
|


Otto Moehrbach[_2_]

Last ActiveCell
 
Jim
Maybe I just missed something, but the OP was asking how to find the
previously selected cell, and a selection change does not get into the Undo
buffer. Hitting Undo will take him back to the previous cell only if he
changed the contents of that cell. What did I miss? Otto
"Jim Rech" wrote in message
...
Ctrl-z is Undo.

--
Jim
"Otto Moehrbach" wrote in message
...
| Bob
| Is there some reference that has to be active for this Ctrl-Z to
work?
| I have 2002 and Ctrl-Z doesn't do anything for me. Thanks for your
time.
| Otto
| "Bob Phillips" wrote in message
| ...
| Ctrl-Z will take you back there.
|
| --
| __________________________________
| HTH
|
| Bob
|
| "Steven" wrote in message
| ...
| When you change cells is there a way to tell which was the last
active
| cell.
|
| Thank you,
|
| Steven
|
|
|



Jim Rech

Last ActiveCell
 
You interpreted his "last activecell" as "previously selected cell". Just
as valid is the last active cell in the sheet (gotten to via {End}{Home}).
However I was just saying what Ctrl-z was since I thought you were asking.
I have no opinion on the efficacy of Bob's suggestion<g.

--
Jim
"Otto Moehrbach" wrote in message
...
| Jim
| Maybe I just missed something, but the OP was asking how to find the
| previously selected cell, and a selection change does not get into the
Undo
| buffer. Hitting Undo will take him back to the previous cell only if he
| changed the contents of that cell. What did I miss? Otto
| "Jim Rech" wrote in message
| ...
| Ctrl-z is Undo.
|
| --
| Jim
| "Otto Moehrbach" wrote in message
| ...
| | Bob
| | Is there some reference that has to be active for this Ctrl-Z to
| work?
| | I have 2002 and Ctrl-Z doesn't do anything for me. Thanks for your
| time.
| | Otto
| | "Bob Phillips" wrote in message
| | ...
| | Ctrl-Z will take you back there.
| |
| | --
| | __________________________________
| | HTH
| |
| | Bob
| |
| | "Steven" wrote in message
| | ...
| | When you change cells is there a way to tell which was the last
| active
| | cell.
| |
| | Thank you,
| |
| | Steven
| |
| |
| |
|
|


BillCPA

Last ActiveCell
 
Not sure who Otto and Jim are or why they are so combative.

I was looking for the same thing today and came across your question.
Kent's idea is pretty close, and I worked from that. Here is what I ended up
with.

Define a couple of Public strings: ThisCell and LastCell. Then in your
Sheet Module, put this:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

LastCell = ThisCell
ThisCell = ActiveCell.Address

End Sub

You may also want to initialize ThisCell in the Workbook_Open module.

Then each time you move to a different cell, LastCell will give you the cell
address of the previous cell.

--
Bill @ UAMS


"Steven" wrote:

When you change cells is there a way to tell which was the last active cell.

Thank you,

Steven



All times are GMT +1. The time now is 10:05 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com