Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default go back/previous cell

is there any way to go back to a previous cell? Say am in a1 and hit enter
(or tab), is there any way programmibly to get back to the cell (or at least
get it's address) automatically with out knowing the cells name or position.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 111
Default go back/previous cell

Indirectly, there is a way, though not sure how it would work when you have
multiple cells selected. Check out both SelectionChange and Change events
on both the worksheet and workbook level.

SelectionChange is the event that I have had to use as well as having module
level (or in this case worksheet level) variables setup and they retain
their values so as when the selection of cell(s) has been changed, it knows
what was selected prior to the change.

The Target variable contains the new range/group of cell(s) selected, after
the change took place. I doubt though this event would be triggered if
multiple cells are selected and you just hit the tab or enter key.

At the end of the code, the variables would need to be set to the new
selection so as at the beginning of the code, it can use that selection to
set the focus on via the Select Method, should you want to have it do that.

--
Ronald R. Dodge, Jr.
Production Statistician/Programmer
Master MOUS 2000

"jasminesy" wrote in message
...
is there any way to go back to a previous cell? Say am in a1 and hit

enter
(or tab), is there any way programmibly to get back to the cell (or at

least
get it's address) automatically with out knowing the cells name or

position.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default go back/previous cell

jasminesy,

Put this into a regular codemodule:

Option Explicit
Public OldCell As Range
Public NewCell As Range

Sub GoBack()
OldCell.Select
End Sub


Put this into the worksheet's codemodule (copy the code, right click on the sheet tab, select "View
Code" and paste into the window that appears:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If OldCell Is Nothing Then
Set OldCell = Target
Else
Set OldCell = NewCell
Set NewCell = Target
End If
End Sub


Then when you want to go back to the previous selection run the macro "GoBack"

HTH,
Bernie
MS Excel MVP


"jasminesy" wrote in message
...
is there any way to go back to a previous cell? Say am in a1 and hit enter
(or tab), is there any way programmibly to get back to the cell (or at least
get it's address) automatically with out knowing the cells name or position.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default go back/previous cell

Thank You, Thank You, Thank you.

"Bernie Deitrick" wrote:

jasminesy,

Put this into a regular codemodule:

Option Explicit
Public OldCell As Range
Public NewCell As Range

Sub GoBack()
OldCell.Select
End Sub


Put this into the worksheet's codemodule (copy the code, right click on the sheet tab, select "View
Code" and paste into the window that appears:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If OldCell Is Nothing Then
Set OldCell = Target
Else
Set OldCell = NewCell
Set NewCell = Target
End If
End Sub


Then when you want to go back to the previous selection run the macro "GoBack"

HTH,
Bernie
MS Excel MVP


"jasminesy" wrote in message
...
is there any way to go back to a previous cell? Say am in a1 and hit enter
(or tab), is there any way programmibly to get back to the cell (or at least
get it's address) automatically with out knowing the cells name or position.




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default go back/previous cell

Thank You, Thank You, Thank you.


I guess it worked, huh? ;-)

You're welcome.

Bernie
MS Excel MVP




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Go back to the previous excel file houghi Excel Discussion (Misc queries) 2 March 6th 09 04:25 PM
can I get back previous version of a file I copied over in excel? jac34 Excel Discussion (Misc queries) 2 January 24th 06 01:35 AM
Revert back to previous file version vamorv2004 Excel Discussion (Misc queries) 2 May 17th 05 02:07 AM
Go back to previous worksheet BarryL New Users to Excel 2 May 5th 05 01:38 AM
Roll back to previous date Jay Excel Worksheet Functions 2 December 3rd 04 03:35 PM


All times are GMT +1. The time now is 11:54 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"