Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thank You, Thank You, Thank you.
I guess it worked, huh? ;-) You're welcome. Bernie MS Excel MVP |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Go back to the previous excel file | Excel Discussion (Misc queries) | |||
can I get back previous version of a file I copied over in excel? | Excel Discussion (Misc queries) | |||
Revert back to previous file version | Excel Discussion (Misc queries) | |||
Go back to previous worksheet | New Users to Excel | |||
Roll back to previous date | Excel Worksheet Functions |